I have read the PHP manual, but I am not quite familiar with the solution.

Source: Internet
Author: User
Look at the PHP manual, there is a paragraph not quite understanding in the introduction of list, given the following warning: list () assignsthevaluesstartingwiththeright-mostparameter.Ifyouareusingplainvariables, youdonthavetoworryaboutthis. Buti see PHP manual, there is a paragraph not quite understanding
The following warning is provided during the introduction of list:

List () assigns the values starting with the right-most parameter. if you are using plain variables, you don't have to worry about this. but if you are using arrays with indices you usually expect CT the order of the indices in the array the same you wrote in the list () from left to right; which it isn' t. it's assigned in the reverse order.
I don't quite understand the translation. does list have subscripts? Why is the list assigned a value from right to left? What is the opposite of list subscript and array subscript?
I am a newbie. I am very grateful to anyone who wants to answer this question !!!!

------ Solution --------------------
The following are examples in the manual.


$ Info = array ('Coffee ', 'Brown', 'Caffeine ');
List ($ a [0], $ a [1], $ a [2]) = $ info;
Var_dump ($ );

Output


Array (3 ){
[2] =>
String (8) "caffeine"
[1] =>
String (5) "brown"
[0] =>
String (6) "coffee"
}


Can you see the problem ,? If not, run it like this.

$ Info = array ('Coffee ', 'Brown', 'Caffeine ');
List ($ a [], $ a [], $ a []) = $ info;
Var_dump ($ );
------ Solution --------------------
Example 1
PHP code
List ($ a, $ B, $ c) = array (1, 2, 3); print_r (array ($ a, $ B, $ c ));
------ Solution --------------------
You have a Chinese comment! Http://php.net/manual/zh/function.list.php
HTML code
Warninglist () is assigned a value starting from the rightmost parameter. If you use simple variables, don't worry about this. However, if you use an array with indexes, the expected results are usually the same as those written in list (), but they are not. Values are assigned in 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.