note 35386 added to function.list

From: Date: Fri, 29 Aug 2003 10:55:43 +0000
Subject: note 35386 added to function.list
Groups: php.notes 
Request: Send a blank email to php-notes+get-55289@lists.php.net to get a copy of this message
It seems that list() works "backwards". Take this example: $foo = array(); list($foo['a'], $foo['b'], $foo['c']) = array('a', 'b', 'c'); You would expect that $foo now has three values, "a", "b" and "c", and in that order, but in reality the order of the values in $foo is "c", "b" and finally "a". Because of this, this code: foreach ($foo as $key => $val) { echo $key; } Will output "cba" and not "abc", as you might have expected. ---- Manual Page -- http://www.php.net/manual/en/function.list.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35386 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35386&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35386&report=yes

« previous php.notes (#55289) next »