mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
A revision of the mode docs, and made the 0 warning a caution instead.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@135505 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
868a04317f
commit
bf504c0c96
1 changed files with 16 additions and 17 deletions
|
@ -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 @@ $result = count ($b);
|
|||
<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
|
||||
|
|
Loading…
Reference in a new issue