3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on 89btL
Output for 4.3.0 - 7.2.0
Array ( [1] => 1test [2] => 2test [3] => Array ( [1] => 11test [2] => 12test [3] => 13test ) )