note 95622 deleted from function.count by danbrown
| From: | danbrown@php.net | Date: | Wed, 13 Jan 2010 01:55:16 +0000 |
| Subject: | note 95622 deleted from function.count by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164897@lists.php.net to get a copy of this message | ||
Note Submitter: blassmann at hotmail dot com dot com
----
ceo at l-i-e dot com said:
count('') returns the very un-intuitive value of 1...
___
That's kind of retarded, in my opinion. I wish it would just return 0.
For example, in counting files:
$files = glob('*.*')
$indexCount= count($files);
if ($indexCount > 0) . . .
would continue even with zero files, because count still gave a value of "1". I had to
test for truth first:
if ($files = glob('*.*')){ // not ==
$indexCount= count($files);
. . .
}