2008/4/30 Nathan Nobbe <[EMAIL PROTECTED]>:
> On Wed, Apr 30, 2008 at 2:58 PM, Richard Heyes <[EMAIL PROTECTED]> 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;
Because an empty array evaluates to false when cast to bool (which is
implicit in a conditional).
So this should work fine:
if (array_filter($myArray)) {
// only do this if there's stuff worth bothering with in myArray
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php