note 101626 deleted from function.key by danbrown

From: Date: Thu, 30 Dec 2010 19:31:01 +0000
Subject: note 101626 deleted from function.key by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175352@lists.php.net to get a copy of this message
Note Submitter: rmasta at gmail dot com ---- To Dallas at ekkysoftware dot com: You could modify Your code to check for FALSE values that current() outputs when at the end of array, like this: <?php $row = array( 'first'=>'number', 'second'=>'letter', 'third'=>null, 'forth'=>'word'); while(($value = current($row))!==FALSE){ echo "\"".key($row)."\""; next($row); } ?> But then there would remaining the problem of what happens when there are FALSEs in the array. The correct way is, like You said, the following: <?php foreach($row as $value){ echo "\"".key($row)."\""; next($row); } ?>

« previous php.notes (#175352) next »