betz            Sat Jul 19 02:51:27 2003 EDT

  Modified files:              
    /phpdoc/en/reference/array/functions        count.xml 
  Log:
  optional param for count, thanks to Griggs Domler
  
Index: phpdoc/en/reference/array/functions/count.xml
diff -u phpdoc/en/reference/array/functions/count.xml:1.6 
phpdoc/en/reference/array/functions/count.xml:1.7
--- phpdoc/en/reference/array/functions/count.xml:1.6   Wed Jul 16 13:06:57 2003
+++ phpdoc/en/reference/array/functions/count.xml       Sat Jul 19 02:51:26 2003
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
 <!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
   <refentry id="function.count">
    <refnamediv>
@@ -11,7 +11,14 @@
      <methodsynopsis>
       <type>int</type><methodname>count</methodname>
       <methodparam><type>mixed</type><parameter>var</parameter></methodparam>
+      <methodparam 
choice="opt"><type>int</type><parameter>mode</parameter></methodparam>
      </methodsynopsis>
+    <note>
+     <simpara>
+      The optional parameter <parameter>mode</parameter> is available as of 
+      PHP 4.2.0.
+     </simpara>
+    </note>
     <para>
      Returns the number of elements in <parameter>var</parameter>,
      which is typically an <type>array</type> (since anything else will have
@@ -22,6 +29,14 @@
      be returned (exception: <literal>count(&null;)</literal> equals
      <literal>0</literal>).
     </para>
+    <para>
+     The optinal parameter <parameter>mode</parameter> can be supplied to count
+     recursive. To do so, set <parameter>mode</parameter> to
+     <literal>1</literal>, or use the constant
+     <constant>COUNT_RECURSIVE</constant>. The dafault value is
+     <literal>0</literal>. For example, recursive count is usefull counting the
+     elements of multidimensional arrays.
+    </para>
     <warning>
      <para>
       <function>count</function> may return 0 for a variable that
@@ -53,6 +68,28 @@
 $b[10] = 11;
 $result = count ($b);
 // $result == 3;
+?>
+]]>
+      </programlisting>
+     </example>
+    </para>
+    <para>
+     <example>
+      <title>
+       recursive <function>count</function> example (PHP &gt;= 4.2.0)
+      </title>
+      <programlisting role="php">
+<![CDATA[
+<?php
+$food = $food = array( 'fruits'  => array('orange', 'banana', 'apple'),
+                       'veggie'  => array('carrot', 'collard','pea'));
+
+// recursive count
+echo count($food,COUNT_RECURSIVE);  // output 8
+
+// normal count
+echo count($food);                  // output 2
+
 ?>
 ]]>
       </programlisting>



-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to