note 96562 added to function.key

From: Date: Fri, 05 Mar 2010 05:32:22 +0000
Subject: note 96562 added to function.key
Groups: php.notes 
Request: Send a blank email to php-notes+get-166694@lists.php.net to get a copy of this message
I had a problem when there are nulls in your data, such as:- $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:- foreach($row as $value){ echo "\"".key($row)."\""; next($row); } ---- Server IP: 69.147.83.197 Probable Submitter: 203.206.173.235 ---- Manual Page -- http://www.php.net/manual/en/function.key.php Edit -- https://master.php.net/note/edit/96562 Del: integrated -- https://master.php.net/note/delete/96562/integrated Del: useless -- https://master.php.net/note/delete/96562/useless Del: bad code -- https://master.php.net/note/delete/96562/bad+code Del: spam -- https://master.php.net/note/delete/96562/spam Del: non-english -- https://master.php.net/note/delete/96562/non-english Del: in docs -- https://master.php.net/note/delete/96562/in+docs Del: other reasons-- https://master.php.net/note/delete/96562 Reject -- https://master.php.net/note/reject/96562 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166694) next »