Javatpoint Logo
Javatpoint Logo

PHP sizeof() function

The sizeof( ) function is an alias of count( ) function. The sizeof( ) function returns the number of elements in an array. This function was introduced in PHP 4.0.

Syntax

Parameter

Parameter Description Is compulsory
array Specifies the array to use. compulsory
mode 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)
Optional

Returns

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

Example 1

Output:

8

Example 2

Output:

4

Example 3

Output:

5

Example 4

Output:

5





Help Others, Please Share

facebook twitter pinterest