note 110028 deleted from function.list by googleguy
| From: | googleguy@php.net | Date: | Thu, 13 Sep 2012 09:55:55 +0000 |
| Subject: | note 110028 deleted from function.list by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190689@lists.php.net to get a copy of this message | ||
Note Submitter: joshua dot never at gmail dot com
----
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?