Last active
July 6, 2016 08:39
-
-
Save wujunze/92879c651e7d29df2372457e70feefe2 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/*********************** | |
**功能:将多维数组合并为一位数组 | |
**$array:需要合并的数组 | |
**$clearRepeated:是否清除并后的数组中得重复值 | |
***********************/ | |
function array_multiToSingle($array,$clearRepeated=false){ | |
if(!isset($array)||!is_array($array)||empty($array)){ | |
return false; | |
} | |
if(!in_array($clearRepeated,array('true','false',''))){ | |
return false; | |
} | |
static $result_array=array(); | |
foreach($array as $value){ | |
if(is_array($value)){ | |
array_multiToSingle($value); | |
}else{ | |
$result_array[]=$value; | |
} | |
} | |
if($clearRepeated){ | |
$result_array=array_unique($result_array); | |
} | |
return $result_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment