note 110028 added to function.list

From: Date: Thu, 13 Sep 2012 09:34:17 +0000
Subject: note 110028 added to function.list
Groups: php.notes 
Request: Send a blank email to php-notes+get-190680@lists.php.net to get a copy of this message
In addition to dan dot lugg at gmail dot com's note I changed the values to strings <?php $a = array('1','2','3'); list($c, $b, $a) = $a; var_dump($a, $b, $c); //string(1) "3" //string(0) "" //string(1) "3" ?> This is interesting that $b becomes empty string( in stead of NULL) while $c is correctly assigned. I figured out that $b is assigned the second char in $a, and $c is assigned the first char in $a. How does this happen? <?php $a = array('','','','1234'); list($d,$c, $b, $a) = $a; var_dump($a, $b, $c,$d); //string(4) "1234" //string(1) "3" //string(1) "2" //string(1) "1" ?> and dealing with a string: <?php $string = '1234'; list($d,$c, $b, $a) = $string; var_dump($a, $b, $c,$d); //string(1) "4" //string(0) "3" //string(0) "2" //string(1) "1" ?> According to the manual:list() only works on numerical arrays But in this case '1234' equals array('1','2','3','4') Can anyone explane this? ---- Server IP: 69.147.83.197 Probable Submitter: 121.236.55.238 ---- Manual Page -- http://www.php.net/manual/en/function.list.php Edit -- https://master.php.net/note/edit/110028 Del: integrated -- https://master.php.net/note/delete/110028/integrated Del: useless -- https://master.php.net/note/delete/110028/useless Del: bad code -- https://master.php.net/note/delete/110028/bad+code Del: spam -- https://master.php.net/note/delete/110028/spam Del: non-english -- https://master.php.net/note/delete/110028/non-english Del: in docs -- https://master.php.net/note/delete/110028/in+docs Del: other reasons-- https://master.php.net/note/delete/110028 Reject -- https://master.php.net/note/reject/110028 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190680) next »