Home >php教程 >php手册 >递归更改数组(键名) 支持多层嵌套

递归更改数组(键名) 支持多层嵌套

WBOY
WBOYOriginal
2016-06-06 19:39:011183browse

无详细内容 无 /**递归更改数组(键名) 支持多层嵌套*@param $arr array*@param $stat int 0小写 1大写*/function array_change_key_case_d($arr,$stat=0){$func=$stat?"strtoupper":"strtolower";$_newArr=array();if(!is_array($arr)||empty($arr)){return $

/*
*递归更改数组(键名) 支持多层嵌套
*@param  $arr array
*@param  $stat int 0小写 1大写
*/
function array_change_key_case_d($arr,$stat=0){
	$func=$stat?"strtoupper":"strtolower";
	$_newArr=array();
	if(!is_array($arr)||empty($arr)){
		return $_newArr;
		}
	foreach($arr as $k=>$v){
		$_key=$func($k);
		$_newArr[$_key]=is_array($v)?array_change_key_case_d($v,$stat):$v;
		}	
	return $_newArr;	
	}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn