Easy Tutorial
❮ Func String Implode Func Math Tan ❯

PHP count() Function

Complete PHP Array Reference Manual

Example

Returns the number of elements in an array:


Definition and Usage

The count() function returns the number of elements in an array.


Syntax

Parameter Description
array Required. Specifies the array to count.
mode Optional. Specifies the mode of the function. Possible values: 0 - Default. Does not count all elements in a multidimensional array. <br> 1 - Recursively counts the number of elements in an array (counts all elements in a multidimensional array).

Technical Details

Return Value: Returns the number of elements in the array.
PHP Version: 4+
--- ---
Changelog: The mode parameter was added in PHP 4.2.
--- ---

More Examples

Example 1

Recursively counts the number of elements in an array:


❮ Func String Implode Func Math Tan ❯