//过滤掉空值 function filter_array($arr, $values = ['',[]]){ foreach ($arr as $k => $v) { if (is_array($v) && count($v)>0) { $arr[$k] = filter_array($v, $values); } foreach ($values as $value) { if ($v === $value) { unset($arr[$k]); break; } } } return $arr; }
//过滤掉空值 function filter_array($arr){ $narr = array(); while(list($key, $val) = each($arr)){ if (is_array($val)){ $val = filter_array($val); if (count($val)!=0){ $narr[$key] = $val; } }else{ if (trim($val) != ""){ $narr[$key] = $val; } } } unset($arr); return $narr; }