3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=[ ["2015年5月", "---", "---"], ["2015年12月", "(2016年1月20日)", "---"], ["2016年6月", "(2016年7月16日)", "---"] ]; // Aパターン $arr2=[]; foreach ($arr as $key => $value) { $arr2[]=preg_replace("/---/","000", $value); print_r($arr2); } // Bパターン $arr2=[]; foreach ($arr as $key => $value) { $arr2[]=preg_replace("/---/","000", $value); } print_r($arr2);

preferences:
30.36 ms | 402 KiB | 5 Q