note 26104 added to function.list

From: Date: Fri, 18 Oct 2002 06:09:22 +0000
Subject: note 26104 added to function.list
Groups: php.notes 
Request: Send a blank email to php-notes+get-38230@lists.php.net to get a copy of this message
list() does some strange things with re-ordering array elements. $baz = array(1,2,3) # print_r($baz) shows: # Array ( [0] => 1 [1] => 2 [2] => 3 ) # then: $foo = "a:b:c"; list($bar[0],$bar[1],$bar[2]) = split(":",$foo); # print_r($baz) shows: # Array ( [2] => c [1] => b [0] => a ) # list() has assigned them backwards AND re-ordered the keys of the array. list($baz[2],$baz[1],$baz[0]) = split(":",$foo); # Array ( [0] => c [1] => b [2] => a ) print join(":",$bar); print join(":",$baz); # BOTH print "c:b:a" This isn't really a bug, but something to watch out for, considering join(":",split(":","a:b:c")) returns "a:b:c" as expected. -- http://www.php.net/manual/en/function.list.php http://master.php.net/manage/user-notes.php?action=edit+26104 http://master.php.net/manage/user-notes.php?action=delete+26104 http://master.php.net/manage/user-notes.php?action=reject+26104

« previous php.notes (#38230) next »