count()


int count ( bool/int/float/string/array $var [, int $mode = COUNT_NORMAL] )

Description

count() counts all elements in an array or a variable

※ available F/W version : all

Parameters

Return values

Returns the number of elements in the array or variable. If the array is empty, returns 0. Otherwise returns 1.

Example

<?php
$a = array(1, 2, 3);

$b1 = array(1, 2, 3);
$b2 = array(4, 5, 6);
$b = array($b1, $b2);

$cnt1 = count($a);
$cnt2 = count($b, COUNT_RECURSIVE);

echo "cnt1: $cnt1, cnt2: $cnt2\r\n"; // OUTPUT: cnt1: 3, cnt2: 8 
?>

See also

None

Remarks

This function is identical to the PHP group’s count() function.