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

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

WBOY
Release: 2016-06-06 19:39:01
Original
1162 people have browsed it

无详细内容 无 /**递归更改数组(键名) 支持多层嵌套*@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;	
	}
Copy after login
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template