See PHP Manual, there is a paragraph does not understand the solution of the idea

Source: Internet
Author: User
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. 
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.