PHP: Remove an element from an array
Found on this thread
I needed to remove elements from an array that were either blank, nothing but a space, or null.
foreach($array as $key => $value) {
if($value == "" || $value == " " || is_null($value)) {
unset($array[$key]);
}
}
/*
and if you want to create a new array with the keys reordered accordingly…
*/
$new_array = array_values($array);
March 18th, 2008 at 3:10 am
[...] Tnx to Scriptygoddess [...]