Skip to content
Chung Leong edited this page Jan 10, 2022 · 5 revisions

count - Returns the number of elements in an array.

uint32 count( mixed $var [, int32 $mode = COUNT_NORMAL] )

Parameters:

var - The array.

mode - If the optional mode is set to COUNT_RECURSIVE or true, count() returns the total number of primitives (i.e. integers or floats) contained in a multidimensional array.

Return Value:

Returns the number of elements in var. If var is a multidimensional array and mode == COUNT_NORMAL, the return value is the number of subarrays. If mode == COUNT_RECURSIVE, it is the total numbers of primitives.

Notes:

No action actually occurs when you call this function. count() merely returns variables holding an array’s dimensions.

Version

1.0 and above.

Clone this wiki locally