This snippet will remove all the empty values from an array and returns the cleared array. If the input is not an array, it will return false
Example of use:
print_r(clear_empty_values($array));
function clear_empty_values($arr)
{
if (!is_array($arr)) return false;
$new = array();
while(list($k, $v) = each($arr))
{
$v = trim($v);
if ($v != '' || !empty($v)) $new[$k] = $v;
}
return $new;
}
Mail this!
- Comments (0)
- PingBacks (0)
- TrackBacks (0)

» Latest comments