$arr = [ ‘a‘ => ‘A‘, ‘b‘ => ‘B‘, ‘c‘ => [ ‘d‘=> ‘D‘, ‘e‘=>[ ‘f‘=>‘F‘, ‘g‘=>[‘h‘=>‘H‘] ] ] ]; //创建一个数组处理函数 function changeCase($var,$type = CASE_UPPER){ $var = array_change_key_case($var,$type); foreach($var as $key => $value){ if(is_array($value)){ $var[$key]=changeCase($value); } } return $var; } $res = changeCase($arr); pre($res); function pre($var){ echo ‘<pre>‘; print_r($var); echo ‘</pre>‘; }
递归这个数组 把键名 全部换成大写的
时间: 2024-12-23 18:38:22