Files
typecho/tools/transfer-array.php
2016-01-26 12:55:22 +08:00

14 lines
336 B
PHP

<?php
// transfer [] to array()
$file = $argv[1];
$text = file_get_contents($file);
$text = preg_replace("/= \[([^;]*)\];/s", "= array(\\1);", $text);
$text = preg_replace("/(\(| )\[([^\n]*?)\]\)/", "\\1array(\\2))", $text);
$text = preg_replace("/(\(| )\[([^\n]*?)\],/", "\\1array(\\2),", $text);
file_put_contents($file, $text);