Dostupnost ve verzích: PHP 4.0

Counts all elements in an array, or something in an object.

For objects, if you have SPL installed, you can hook into count() by implementing interface {


Parametr Datový typ Výchozí hodnota Poznámka
$var `array Countable`    
$mode int COUNT_NORMAL    

Návratové hodnoty


the number of elements in var, which is typically an array, since anything else will have one element.

If var is not an array or an object with implemented Countable interface, 1 will be returned. There is one exception, if var is &null;, 0 will be returned.

Caution: count may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset to test if a variable is set.

Další zdroje…on.count.php

Sponzorované odkazy
Pomohl Vám tento článek?