philip Sun Jul 20 12:59:16 2003 EDT
Modified files:
/phpdoc/en/reference/array/functions count.xml
Log:
A revision of the mode docs, and made the 0 warning a caution instead.
Index: phpdoc/en/reference/array/functions/count.xml
diff -u phpdoc/en/reference/array/functions/count.xml:1.7
phpdoc/en/reference/array/functions/count.xml:1.8
--- phpdoc/en/reference/array/functions/count.xml:1.7 Sat Jul 19 02:51:26 2003
+++ phpdoc/en/reference/array/functions/count.xml Sun Jul 20 12:59:16 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.count">
<refnamediv>
@@ -13,12 +13,6 @@
<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
@@ -29,22 +23,27 @@
be returned (exception: <literal>count(&null;)</literal> equals
<literal>0</literal>).
</para>
+ <note>
+ <simpara>
+ The optional <parameter>mode</parameter> parameter is available as of
+ PHP 4.2.0.
+ </simpara>
+ </note>
<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.
+ If the optional <parameter>mode</parameter> parameter is set to
+ <constant>COUNT_RECURSIVE</constant> (or 1), <function>count</function>
+ will recursivly count the array. This is particularly useful for
+ counting all the elements of a multidimensional array. The default
+ value for <parameter>mode</parameter> is <literal>0</literal>.
</para>
- <warning>
+ <caution>
<para>
<function>count</function> may return 0 for a variable that
isn't set, but it may also return 0 for a variable that has
been initialized with an empty array. Use
<function>isset</function> to test if a variable is set.
</para>
- </warning>
+ </caution>
<para>
Please see the <link linkend="language.types.array">Arrays</link>
section of the manual for a detailed explanation of how arrays
@@ -81,8 +80,8 @@
<programlisting role="php">
<![CDATA[
<?php
-$food = $food = array( 'fruits' => array('orange', 'banana', 'apple'),
- 'veggie' => array('carrot', 'collard','pea'));
+$food = array( 'fruits' => array('orange', 'banana', 'apple'),
+ 'veggie' => array('carrot', 'collard','pea'));
// recursive count
echo count($food,COUNT_RECURSIVE); // output 8
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php