Skip to content

Instantly share code, notes, and snippets.

@GerBawn
Last active September 23, 2015 08:27
Show Gist options
  • Save GerBawn/d63212851e204e2352f3 to your computer and use it in GitHub Desktop.
Save GerBawn/d63212851e204e2352f3 to your computer and use it in GitHub Desktop.
数组辅助函数
<?php
/**
* 不支持大小写,但速度较快
*/
function array_change_key_case_recursive($arr, $case){
return array_map(function($item){
if(is_array($item))
return array_change_key_case_recursive($item, $case);
}, array_change_key_case($arr, $case));
}
/**
*支持大小写, 但速度较慢
*
*/
function array_change_key_case_recursive1($arr, $case = CASE_LOWER){
$arr = array_change_key_case($arr, $case);
foreach($arr as $key => $item){
if(is_array($item))
$arr[$key] = array_change_key_case_recursive1($item, $case);
}
return $arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment