add a missing ; in the example (user complaining)

document the fact that <?php echo {[bar]}; ?> is possible (user too)
Having a trailing comma in the array declaration is valid. (raised by Jason Garber on php.internals)
See also count() while we are here :)


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@161634 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2004-06-17 21:26:19 +00:00
parent dc2698a20f
commit 06d4bd0ab4

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<!-- $Revision: 1.12 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.110 -->
<refentry id="function.array">
<refnamediv>
@ -36,6 +36,10 @@
be the biggest integer index + 1. Note that when two identical
index are defined, the last overwrite the first.
</para>
<para>
Having a trailing comma after the last defined array entry, while
unusual, is a valid syntax.
</para>
<para>
The following example demonstrates how to create a
two-dimensional array, how to specify keys for associative
@ -50,7 +54,7 @@ $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>
@ -118,9 +122,27 @@ Array
</screen>
</example>
</para>
<para>
As in Perl, you can access a value from the array inside double quotes.
However, with PHP you'll need to enclose your array between curly braces.
<example>
<title>Accessing an array inside double quotes</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = array('bar' => 'baz');
echo "Hello {$foo['bar']}!"; // Hello baz!
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>array_pad</function>,
<function>list</function>,
<function>count</function>,
<link linkend="control-structures.foreach">foreach</link>, and
<function>range</function>.
</para>