Last active
September 23, 2015 08:27
-
-
Save GerBawn/d63212851e204e2352f3 to your computer and use it in GitHub Desktop.
数组辅助函数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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