首页 > 代码库 > PHP递归题目

PHP递归题目

$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>‘;}

 递归这个数组 把键名 全部换成大写的

PHP递归题目