- var_export: documentation ( source)
- strtoupper: documentation ( source)
<?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));