cvs: phpdoc /en/functions array.xml

From: Date: Wed, 29 Nov 2000 19:47:41 +0000
Subject: cvs: phpdoc /en/functions array.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969333120@lists.php.net to get a copy of this message
dams Wed Nov 29 11:47:41 2000 EDT Modified files: /phpdoc/en/functions array.xml Log: Adding details and examples to indexes behaviors. Index: phpdoc/en/functions/array.xml diff -u phpdoc/en/functions/array.xml:1.43 phpdoc/en/functions/array.xml:1.44 --- phpdoc/en/functions/array.xml:1.43 Tue Oct 17 22:46:56 2000 +++ phpdoc/en/functions/array.xml Wed Nov 29 11:47:41 2000 @@ -50,6 +50,14 @@ </note> </para> <para> + Syntax "index =&gt; values", separated by commas, define index + and values. index may be of type string or numeric. When index is + omitted, a integer index is automatically generated, starting + at 0. If index is an integer, next generated index will + be the biggest integer index + 1. Note that when two identical + index are defined, the last overwrite the first. + </para> + <para> The following example demonstrates how to create a two-dimensional array, how to specify keys for associative arrays, and how to skip-and-continue numeric indices in normal @@ -64,6 +72,50 @@ ); </programlisting> </example> + </para> + <para> + <example> + <title>Automatic index with <function>Array</function></title> + <programlisting role="php"> +$array = array( 1, 1, 1, 1, 1, 8=>1, 4=>1, 19, 3=>13); +print_r($array); + </programlisting> + </example> + which will display : + <informalexample> +Array +( + [0] => 1 + [1] => 1 + [2] => 1 + [3] => 13 + [4] => 1 + [8] => 1 + [9] => 19 +) + </informalexample> + Note that index '3' is defined twice, and keep its final value of 13. + Index 4 is defined after index 8, and next generated index (value 19) + is 9, since biggest index was 8. + </para> + <para> + This example creates a 1-based array. + <example> + <title>1-based index with <function>Array</function></title> + <programlisting role="php"> + $firstquarter = array(1 => 'January', 'February', 'March'); + print_r($firstquarter); + </programlisting> + </example> + which will display : + <informalexample> +Array +( + [1] => 'January' + [2] => 'February' + [3] => 'March' +) + </informalexample> </para> <para> See also: <function>list</function>.

« previous php.doc (#969333120) next »