Re: [PHP] check if any element of an array is not "empty"

[email protected] (tedd)
Newsgroups php.general
Message-ID <p06240801c44018b88e2e@[192.168.1.101]>
At 3:36 PM -0500 4/30/08, afan pasalic wrote:
>hi,
>as a result of one calculation I'm receiving an array where elements
>could be 0 or date (as string yyyy-mm-dd hh:ii:ss).
>I have to check if any of elements of the array is "date" or if all
>elements of the array is 0?
>
>If I try array_sum($result) I'll get 0 no matter what (0 + $string = 0).
>
>I know I can do something like:
>foreach($result as $value)
>{
>     if ($value !=0)
>     {
>        $alert = true;
>     }
>}
>
>or
>
>if (in_array($result, '-'))
>{
>     $alert = true;
>}
>
>
>but I was thinking if there is the function does that.
>
>thanks for any help.
>
>-afan


You can create an empty array and check to see if the difference via 
array_diff.

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.