递归多维数组键值转大小写
<?php
$database = [
'host' => 'LOCalhosT',
'post' => '3306',
'username' => 'Admin',
'password' => 'adMin888',
'config' => [
'redis' => '127.0.0.1',
'post' => 6379,
'database' => 'ZHANG'
]
];
function my_array_value_case(array $data , int $case = CASE_LOWER) : array{
$action = $case ? 'strtoupper' : 'strtolower';
foreach($data as $key => $value):
$data[$key] = is_array($value) ? my_array_value_case($value) : $action($value);
endforeach;
return $data;
}
print_r(my_array_value_case($database));