Date: 11/29/00
- Next message: Jani Taskinen: "Re: [PHP-DOC] /en/functionsldap.xml"
- Previous message: Damien Seguy: "[PHP-DOC] cvs: phpdoc /fr/functions info.xml"
- Next in thread: Jesus M. Castagnetto: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Maybe reply: Jesus M. Castagnetto: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 => 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>.
- Next message: Jani Taskinen: "Re: [PHP-DOC] /en/functionsldap.xml"
- Previous message: Damien Seguy: "[PHP-DOC] cvs: phpdoc /fr/functions info.xml"
- Next in thread: Jesus M. Castagnetto: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Maybe reply: Jesus M. Castagnetto: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

