Re: Removing empty elements from an array
| From: | eric dot coleman at zaireweb dot com | Date: | Sun, 28 Apr 2002 14:57:19 +0000 |
| Subject: | Re: Removing empty elements from an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94994@lists.php.net to get a copy of this message | ||
function filter($array)
{
if ( !is_array($array) )
{
die("Must be an array!");
}
foreach($array as $key => $value)
{
if($array[$key] == "")
{
unset($array[$key]);
}
}
return($array);
}
----- Original Message -----
From: "Craig Westerman" <westerman@chanuteks.com>
To: "php-general-list" <php-general@lists.php.net>
Sent: Sunday, April 28, 2002 10:36 AM
Subject: [PHP] Removing empty elements from an array
> I have an array that contains several empty elements. What is simplest way
> to remove these elements?
>
> Array ( [0] => [1] =>
> [2] =>
> [3] => 16/Mar/02
> [4] =>
> [5] => 17/Mar/02
> [6] => 18/Mar/02
> [7] => 19/Mar/02
> [8] => 20/Mar/02
> [9] => 21/Mar/02
> [10] => 22/Mar/02
> [11] => 23/Mar/02
> [12] =>
> [13] => 24/Mar/02
> [14] => 25/Mar/02
> [15] =>)
>
> Thanks
>
> Craig ><>
> westerman@chanuteks.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>