([^<]+)\s?:\s?(.*)([\s\S]*?)#", $content, $matches); foreach ($matches[1] as $i => $name) { $output[] = array( 'id' => $name, 'type' => strip_tags($matches[2][$i]), 'description' => str_replace(array("\n", '. ...'), array(' ', '.'), $matches[3][$i]), ); } if ($output) { $location = str_replace('tools/bin/scripts', '', __DIR__); file_put_contents($location . '/js/wysiwyg/ck-options.json', json_encode($output, JSON_PRETTY_PRINT)); } print "\nTotal: " . count($output) . "\n";