cvs: phpdoc /en/reference/array/functions list.xml

From: Date: Sat, 08 Jun 2002 15:11:31 +0000
Subject: cvs: phpdoc /en/reference/array/functions list.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969346249@lists.php.net to get a copy of this message
mfischer Sat Jun 8 11:11:31 2002 EDT Modified files: /phpdoc/en/reference/array/functions list.xml Log: - Document list() specific behaviour of the order of assigning the values to the variables. Index: phpdoc/en/reference/array/functions/list.xml diff -u phpdoc/en/reference/array/functions/list.xml:1.4 phpdoc/en/reference/array/functions/list.xml:1.5 --- phpdoc/en/reference/array/functions/list.xml:1.4 Sun May 12 04:19:28 2002 +++ phpdoc/en/reference/array/functions/list.xml Sat Jun 8 11:11:31 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/array.xml, last change in rev 1.2 --> <refentry id="function.list"> <refnamediv> @@ -78,6 +78,44 @@ ]]> </programlisting> </example> + </para> + <warning> + <para> + <function>list</function> 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 + <function>list</function> from left to write; which it isn't. It's + assigned in the reverse order. + </para> + </warning> + <para> + <example> + <title>Using <function>list</function> with array indices</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$info = array('coffee', 'brown', 'caffeine'); + +list($a[0], $a[1], $a[2]) = $info; + +var_dump($a); +]]> + </programlisting> + </example> + Gives the following output (note the order of the elements compared in + which order they were written in the <function>list</function> syntax): + <screen> +array(3) { + [2]=> + string(8) "caffeine" + [1]=> + string(5) "brown" + [0]=> + string(6) "coffee" +} + </screen> </para> <para> See also <function>each</function>, <function>array</function>

« previous php.doc (#969346249) next »