note 58611 added to function.count
| From: | NOSPAM at NOSPAM dot com | Date: | Wed, 09 Nov 2005 15:18:41 +0000 |
| Subject: | note 58611 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98334@lists.php.net to get a copy of this message | ||
markis dot brachel at ntlworld dot com had a slight error in his comments that may confuse people.
<?
// Set up the array
$holes = array ("first", 2 => "second", 5 => "fifth",
"sixth");
// Note blank entries 3 and 4
//count number of entries, this time its 4
$array_count = count($holes);
for($y=0; $y<$array_count; $y++) {
if(isset($holes[$y])) {
echo($holes[$y]);
}
else { $array_count++; }
}
// In the middle, check where array entry exists
// If not, then increase the size of array_count
// to reflect gaps in array.
?>
It says:
Note blank entries 3 and 4
But entry 1 is blank too ("first" 's key=0, "second" 's key=2, 1 is
missing also, array starts at 0 by default)
----
Manual Page -- http://www.php.net/manual/en/function.count.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58611
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58611&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58611&report=yes
Search -- http://master.php.net/manage/user-notes.php