php从数组中删除空白的元素(包括只有空白字符的元素)

/*
 *$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;
            }
        }
    }
}
原文地址:https://www.cnblogs.com/seanpan/p/13993324.html