From 5fad7fe088d8d224339788cde98a014cf4daa9c8 Mon Sep 17 00:00:00 2001 From: Aidan Lister Date: Tue, 2 Nov 2004 23:41:00 +0000 Subject: [PATCH] Fixed typo in last commit (count not coun). Added further examples. Used docbook markup appropriately. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@171989 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/array/functions/count.xml | 48 +++++++++++++++++------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index c0d051e94d..774e3bfd14 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -1,10 +1,10 @@ - + count - Count elements in a variable + Count elements in an array or an object Description @@ -15,20 +15,23 @@ Returns the number of elements in var, - which is typically an array (since anything other than objects - will have one element). + which is typically an array, since anything other than objects + will have one element. - For objects it returns the number of non static properties not taking - visibility into account. If you have SPL starting from PHP 5.1 you can - hook into coun() by implementing interface Countable. That interface - has exactly one method named count() which delivers the return value - for the count() function. + For objects count will return the number of non static + properties, not taking visibility into account. If you have + SPL installed, you can hook into + count by implementing interface + Countable. The interface has exactly one method, + count, which returns the return value for the + count function. - If var is not an array, 1 will - be returned (exception: count(&null;) equals - 0). + If var is not an array or an object, + 1 will be returned. + There is one exception, if var is &null;, + 0 will be returned. @@ -53,7 +56,7 @@ - Please see the Arrays + Please see the Array section of the manual for a detailed explanation of how arrays are implemented and used in PHP. @@ -61,7 +64,6 @@ <function>count</function> example - foo = 'A property'; +$obj->bar = 'Another property'; +$result = count($obj); +// $result == 2; ?> ]]> @@ -102,12 +116,6 @@ echo count($food); // output 2 - - - The sizeof function is an - alias for count. - - See also is_array, isset, and