3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array (1=>1, 2=> 2, 3 => array(1=>11, 2=>12, 3=>13)); $text = "test"; function modarr($array, $text) { foreach ($array as $key => $arr) { if(is_array($arr)) $res[$key] = modarr($arr,$text); // modification function here else $res[$key] = $arr.$text; } return $res; } $erg = modarr($array, $text); print_r($erg);

preferences:
53.96 ms | 402 KiB | 5 Q