didou           Thu Jun 17 17:26:20 2004 EDT

  Modified files:              
    /phpdoc/en/reference/array/functions        array.xml 
  Log:
  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 :)
  
http://cvs.php.net/diff.php/phpdoc/en/reference/array/functions/array.xml?r1=1.11&r2=1.12&ty=u
Index: phpdoc/en/reference/array/functions/array.xml
diff -u phpdoc/en/reference/array/functions/array.xml:1.11 
phpdoc/en/reference/array/functions/array.xml:1.12
--- phpdoc/en/reference/array/functions/array.xml:1.11  Sun Aug 17 08:21:03 2003
+++ phpdoc/en/reference/array/functions/array.xml       Thu Jun 17 17:26:19 2004
@@ -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>
@@ -37,6 +37,10 @@
      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
      arrays, and how to skip-and-continue numeric indices in normal
@@ -50,7 +54,7 @@
     "fruits"  => array("a" => "orange", "b" => "banana", "c" => "apple"),
     "numbers" => array(1, 2, 3, 4, 5, 6),
     "holes"   => array("first", 5 => "second", "third")
-)
+);
 ?>
 ]]>
       </programlisting>
@@ -119,8 +123,26 @@
      </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>

Reply via email to