#!/usr/bin/php $d) { $tag2link[$key]['formatter'][$i]['operator'] = $entry['operatorLabel']['value']; } } continue; } } else { $tag2link[$key] = array( 'label' => $entry['itemLabel']['value'], 'formatter' => array(), ); } $formatter = array( 'link' => $link, ); if (array_key_exists('operatorLabel', $entry)) { $formatter['operator'] = $entry['operatorLabel']['value']; print "{$formatter['operator']}\n"; } else if (preg_match("/^https?:\/\/([^\/]*)(\/.*|)$/", $link, $m)) { $formatter['operator'] = $m[1]; } $tag2link[$key]['formatter'][] = $formatter; } } file_put_contents('dist/tag2link.json', json_encode($tag2link, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));