Javatpoint Logo
Javatpoint Logo

PHP array_count() function

The count( ) function is an inbuilt function of PHP, and it is used to count the elements of an array or the properties of an object. This function was introduced in PHP 4.0.

Syntax

Parameters

Parameter Description Is compulsory
array The input array. compulsory
Mode The specification can take two possible values, either 0 or 1. One generally indicates to count the values of the array recursively. This helps in counting the multidimensional array. The default value is 0 or False. Optional

Return

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

Example 1

Output:

5

Example 2

Output:

3

Example 3

Output:

7

Example 4

Output:

4





Help Others, Please Share

facebook twitter pinterest