时间:2021-07-01 10:21:17 帮助过:3人阅读
$array=array( "22", "1234", array( "a", array("aab","00000","aaa","222000","3333000"), "aa","999","aaaa"), "d", "567", "33", "dsf");function digui($arr) { $fl_array = array(); foreach($arr as $key=>$value) { if(is_array($value)) { $fl_array = array_merge($fl_array, digui($value)); } } $fl_array = array_merge($fl_array, @preg_grep("/\d+/", $arr)); return $fl_array;}print_r(digui($array));Array
$result=array();global $result;function getNum($arr){ global $result; foreach ($arr as $value) { if(is_array($value)){ getNum($value); } if(is_numeric($value)){ array_push($result, $value); } } return $result;}print_r(getNum($array));这样好像也可以