note 82422 deleted from function.array-pop by felipe
| From: | felipe@php.net | Date: | Thu, 10 Apr 2008 22:03:19 +0000 |
| Subject: | note 82422 deleted from function.array-pop by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-138121@lists.php.net to get a copy of this message | ||
Note Submitter: Aditya P Bhatt (adityabhai at gmail dot com)
----
<?
/*
function To Remove a single element from an array
*/
$array = array("1" => "1", "2" => "2", "3"
=> "3", "4" => "4");
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);
?>