3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shortenedRecursiveExport(&$data, $depth = 0) { foreach ($data as $key => $value) { if (is_array($value)) { shortenedRecursiveExport($data[$key], $depth + 1); } } } $data = [ ['k' => [0, 1]], ['k' => [2, 3]], ]; echo 'pre: ' . json_encode($data) . "\n"; shortenedRecursiveExport($data); array_replace_recursive($data[0], $data[1]); echo 'post: ' . json_encode($data) . "\n";

preferences:
47.19 ms | 402 KiB | 5 Q