note 95622 added to function.count
| From: | blassmann at c18-ss-2-lb dot cnet dot com | Date: | Wed, 13 Jan 2010 01:23:10 +0000 |
| Subject: | note 95622 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164895@lists.php.net to get a copy of this message | ||
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);
. . .
}
----
Server IP: 69.147.83.197
Probable Submitter: 116.122.221.48
----
Manual Page -- http://www.php.net/manual/en/function.count.php
Edit -- https://master.php.net/note/edit/95622
Del: integrated -- https://master.php.net/note/delete/95622/integrated
Del: useless -- https://master.php.net/note/delete/95622/useless
Del: bad code -- https://master.php.net/note/delete/95622/bad+code
Del: spam -- https://master.php.net/note/delete/95622/spam
Del: non-english -- https://master.php.net/note/delete/95622/non-english
Del: in docs -- https://master.php.net/note/delete/95622/in+docs
Del: other reasons-- https://master.php.net/note/delete/95622
Reject -- https://master.php.net/note/reject/95622
Search -- https://master.php.net/manage/user-notes.php