protected function removeNullElements($array)
    {
        foreach ($array as $key => $val) {
            if (is_array($val)) {
                $array[$key] = $this->removeNullElements($val);
            } elseif (is_null($val)) {
                unset($array[$key]);
            }
        }

        return $array;
    }
protected function removeNullElements($array)
    {
        foreach ($array as $key => $val) {
            if (is_array($val)) {
                $array[$key] = $this->removeNullElements($val);
            } elseif (is_null($val)) {
                unset($array[$key]);
            }
        }

        return $array;
    }
protected function removeNullElements ( $ array ) { foreach ( $ array as $ key => $ val ) { if ( is_array ( $ val ) ) { $ array [ $ key ] = $ this -> removeNullElements ( $ val ) ; } elseif ( is_null ( $ val ) ) { unset ( $ array [ $ key ] ) ; } } return $ array ; }
Recursively remove null elements.

@param array $array  the array to remove null elements from

@return array
Recursively remove null elements .