note 2188 modified in count by ronabop
| From: | ronabop@php.net | Date: | Wed, 04 Oct 2000 14:38:45 +0000 |
| Subject: | note 2188 modified in count by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6020@lists.php.net to get a copy of this message | ||
To save some time, which I have lost figuring this out.... It was mentioned, by another user for
the sizeof() function, that the results returned may not be what you suspect.
Empty values in an array are not counted, for example:
$a["1"] = "Hello"
$a["2"] = ""
$a["3"] = "Fruit"
Using count($a) would return 2 not 3 since $a["3"] is empty. The fix is to have a
precount variable setup that contains the actual count you want, in this case $b = 3.
http://www.php.net/manual/function.count.php