Re: If array()
| From: | Jochem Maas | Date: | Tue, 10 Oct 2006 09:40:10 +0000 |
| Subject: | Re: If array() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242892@lists.php.net to get a copy of this message | ||
Philipp Schwarz wrote:
> Try this:
>
> if (is_array($array) && count($array)) {
given that your not interested in the actual count of the array,
only that is is not empty, save yourself a couple of CPU cycles
and use empty() instead ...
if (is_array($array) && !empty($array)) {
foreach ($array as $k => $v) echo htmlentities("$v = $k<br />");
}
> ...
> }
>
> John Taylor-Johnston schrieb:
>> How can I use "if" to see an array contains something?
>>
>> if ($array()) does not work, of course.
>>
>> John
>>
>
>