Re: Re: unset empty elements in an array
| From: | Justin French | Date: | Tue, 13 Jul 2004 05:57:57 +0000 |
| Subject: | Re: Re: unset empty elements in an array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190315@lists.php.net to get a copy of this message | ||
On 13/07/2004, at 3:14 AM, Paul Bissex wrote:
How about array_filter()? From the docs: "If the callback function is
not supplied, array_filter() will remove all the entries of input
that are equal to FALSE."
$a = array ('a' => 'foo', 'b' => '', 'c' => null, 'd' => 99, 'e' => 0);
print_r (array_filter ($a));
// Output:
Array
(
[a] => foo
[d] => 99
)
As a previous poster noted, though, this will only work for you if "0"
and the empty string et al. are not significant in your application.
Nice idea Paul, will try it out :)
---
Justin French
http://indent.com.au