note 96562 deleted from function.key by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 12:15:36 +0000 |
| Subject: | note 96562 deleted from function.key by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197108@lists.php.net to get a copy of this message | ||
Note Submitter: Dallas at ekkysoftware dot com
----
I had a problem when there are nulls in your data, such as:-
<?php
$row = array( 'first'=>'number', 'second'=>'letter',
'third'=>null, 'forth'=>'word');
while($value = current($row)){
echo "\"".key($row)."\"";
next($row);
}
?>
The problem is that current() returns the value 'null', but it isn't the end of the
list. To get the correct results I used:-
<?php
foreach($row as $value){
echo "\"".key($row)."\"";
next($row);
}
?>