php数组怎么去掉null元素

$arr = array(1,2,null," ",null,"",3,4);
foreach ($arr as $k => $v){
    if($v==null){
        unset($arr[$k]);
    }
}

var_dump($arr);