Re: check if any element of an array is not "empty"
| From: | Nathan Nobbe | Date: | Wed, 30 Apr 2008 22:26:38 +0000 |
| Subject: | Re: check if any element of an array is not "empty" | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273746@lists.php.net to get a copy of this message | ||
On Wed, Apr 30, 2008 at 2:58 PM, Richard Heyes <richardh@phpguru.org> wrote:
> but I was thinking if there is the function does that.
>>
>
> array_filter(). Note this:
>
> "If no callback is supplied, all entries of input equal to FALSE (see
> converting to boolean) will be removed."
>
> http://uk3.php.net/manual/en/function.array-filter.php
i dont really see how that gets him the answer without at least checking the
number of elements in the array after filtering it w/ array_filter; which if
he wanted to reuse in several places would make sense to write a simple
function for anyway..
function isSomethingInArray($array) {
if(count(array_filter($array)) > 0) { return true; } else { return
false; }
}
-nathan