From bf504c0c9628a694e309caa42e2818aeaa0918dc Mon Sep 17 00:00:00 2001 From: Philip Olson Date: Sun, 20 Jul 2003 16:59:16 +0000 Subject: [PATCH] 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 --- reference/array/functions/count.xml | 33 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 70d14b2fcf..0d735095f4 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -1,5 +1,5 @@ - + @@ -13,12 +13,6 @@ mixedvar intmode - - - The optional parameter mode is available as of - PHP 4.2.0. - - Returns the number of elements in var, which is typically an array (since anything else will have @@ -29,22 +23,27 @@ be returned (exception: count(&null;) equals 0). + + + The optional mode parameter is available as of + PHP 4.2.0. + + - The optinal parameter mode can be supplied to count - recursive. To do so, set mode to - 1, or use the constant - COUNT_RECURSIVE. The dafault value is - 0. For example, recursive count is usefull counting the - elements of multidimensional arrays. + If the optional mode parameter is set to + COUNT_RECURSIVE (or 1), count + will recursivly count the array. This is particularly useful for + counting all the elements of a multidimensional array. The default + value for mode is 0. - + count 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 isset to test if a variable is set. - + Please see the Arrays section of the manual for a detailed explanation of how arrays @@ -81,8 +80,8 @@ $result = count ($b); 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