/* *$arr = array('', 'test', ' '); *dump($arr);输出结果中将只有 'test' */ public function removeEmpty($arr, $trim = TRUE) { foreach ($arr as $key => $value){ if (is_array($value)){ self::removeEmpty($arr[$key]); } else{ $value = trim($value); if ($value == ''){ unset($arr[$key]); } elseif ($trim){ $arr[$key] = $value; } } } }