diff --git a/reference/array/functions/list.xml b/reference/array/functions/list.xml index 59f4563d87..551225b59f 100644 --- a/reference/array/functions/list.xml +++ b/reference/array/functions/list.xml @@ -1,5 +1,5 @@ - + @@ -79,6 +79,44 @@ while (list ($id, $name, $salary) = mysql_fetch_row ($result)) { + + + 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 + the order of the indices in the array the same you wrote in the + list from left to write; which it isn't. It's + assigned in the reverse order. + + + + + Using <function>list</function> with array indices + + + + + Gives the following output (note the order of the elements compared in + which order they were written in the list syntax): + +array(3) { + [2]=> + string(8) "caffeine" + [1]=> + string(5) "brown" + [0]=> + string(6) "coffee" +} + + See also each, array and extract.