note 58611 deleted from function.count by bjori
| From: | bjori@php.net | Date: | Tue, 03 Apr 2007 12:03:05 +0000 |
| Subject: | note 58611 deleted from function.count by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125038@lists.php.net to get a copy of this message | ||
Note Submitter: NOSPAM at NOSPAM dot com
----
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)