Count elements in list C

PHP count[] Function

PHP Array Reference

Example

Return the number of elements in an array:

Try it Yourself »

Definition and Usage

The count[] function returns the number of elements in an array.

Syntax

count[array, mode]

Parameter Values

Parameter Description
array Required. Specifies the array
mode Optional. Specifies the mode. Possible values:
  • 0 - Default. Does not count all elements of multidimensional arrays
  • 1 - Counts the array recursively [counts all the elements of multidimensional arrays]

Technical Details

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

More Examples

Example

Count the array recursively:

Try it Yourself »
PHP Array Reference

Video liên quan

Chủ Đề