Re: phpdoc /en/functions array.xml
| From: | Damien Seguy | Date: | Wed, 29 Nov 2000 11:53:26 +0000 |
| Subject: | Re: phpdoc /en/functions array.xml | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969333106@lists.php.net to get a copy of this message | ||
Hi all,
Thanks to Adam and Goba for all those answers.
I found the place in the array.xml file that deals with it :
"array.xml"
"
<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
arrays.
<example>
<title><function>Array</function> example</title>
<programlisting role="php">
$fruits = array (
"fruits" => array ("a"=>"orange",
"b"=>"banana",
"c"=>"apple"),
"numbers" => array (1, 2, 3, 4, 5, 6),
"holes" => array ("first", 5 => "second",
"third")
);
</programlisting>
</example>
</para>
"
May be, doc could be more specific on this particular point.
I suggest to add some details to the definition.
Can anyone review it before I commit it, both
content and XML structure?
Thanks.
<refentry id="function.array">
<refnamediv>
<refname>array</refname>
<refpurpose>
Create an array
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>array</function></funcdef>
<paramdef>mixed
<parameter><optional>...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
Returns an array of the parameters. The parameters can be given
an index with the <literal>=></literal> operator.
</para>
<para>
<note>
<para>
<function>Array</function> is a language construct used to
represent literal arrays, and not a regular function.
</para>
</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
arrays.
<example>
<title><function>Array</function> example</title>
<programlisting role="php">
$fruits = array (
"fruits" => array ("a"=>"orange",
"b"=>"banana",
"c"=>"apple"),
"numbers" => array (1, 2, 3, 4, 5, 6),
"holes" => array ("first", 5 => "second",
"third")
);
</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
<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>.
</para>
</refsect1>
</refentry>
Best Regards,
Damien Seguy
====================================
http://www.nexen.net/
l'hebergement dynamique gratuit!
Docs PHP/MySQL en Francais, scripts
====================================