Read the PHP manual, there is a paragraph not quite understand
When introducing the list, the following warning are given:
List () assigns the values starting with the Right-most parameter. If you're using plain variables, you don't have the to worry on this. But if you is using arrays with indices you usually expect the order of the indices in the array the same you wrote in th E list () from left to right; which it isn ' t. It ' s assigned in the reverse order.
I do not quite understand the translation, List has subscript? Why does list assign values from right to left? What was he talking about? list subscript and array subscript opposite?
I am a novice, I hope that the expert to answer, greatly appreciated!!!!
------Solution--------------------
Here's an example of the manual.
$info = Array (' coffee ', ' brown ', ' caffeine ');
List ($a [0], $a [1], $a [2]) = $info;
Var_dump ($a);
Output
Array (3) {
[2]=>
String (8) "Caffeine"
[1]=>
String (5) "Brown"
[0]=>
String (6) "Coffee"
}
See the problem? If not, run like this.
$info = Array (' coffee ', ' brown ', ' caffeine ');
List ($a [], $a [], $a []) = $info;
Var_dump ($a);
------Solution--------------------
Example 1
PHP code
list ($a, $b, $c) = Array (1, 2, 3);p Rint_r (Array ($a, $b, $c));
------Solution--------------------
You said you have Chinese comments! http://php.net/manual/zh/function.list.php
HTML code
wa Rninglist () assigns a value starting from the rightmost parameter. If you use a simple variable, don't worry about it. But if you use an indexed array, you usually expect the results to be as left-to-right as the one written in list (), but not actually. are assigned in the reverse order.