3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = ['a' => ['b' => 'l'], 'c' => 'm', 'd' => ['n' => 'o']]; $actionArray = ['action' => ['b']]; function toUpperRecursive(array $arr) { foreach ($arr as $key => $val) { if (is_array($val)) { $newKey = strtoupper($key); $arr[$newKey] = toUpperRecursive($val); unset($arr[$key]); } elseif (is_string($val)) { // $arr[$key] = strtoupper($val); echo $val; } } return $arr; } echo "before:\n"; var_export($testArray); echo "after:\n"; var_export(toUpperRecursive($testArray));

preferences:
52.14 ms | 402 KiB | 5 Q