The following function will remove all null values from a PHP array. This is especially useful when exploding strings with a post/prefixed delimiter.
function array_remove_null(&$array){ $new_array = array(); foreach($array as $k=>$v){ if($v) $new_array[$k]=$v; } $array=$new_array; }
To use the function simply follow the example below;
array_remove_null($your_array_object);