PHP count function

Last Updated: February 19, 2022

count — Count the number of elements of the array

Syntax

count(Countable|array $value, int $mode = COUNT_NORMAL): int

Supports (PHP 4 , PHP 5, PHP 7, PHP 8)

Parameters

Parameter Description
value target array
mode If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count() will recursively count the array.

Return Value

Returns the number of elements of the array

Example

$numbers = array("1","2","3");
print_r(count($numbers);

Output

3
Test