Gen. partnerAlgotech

PHP funkce count()

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

|
11. září 2019

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 {

Parametry

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

int

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

Oficiální dokumentace funkce count

Načítání komentářů...

Zůstaňte v obraze

Přihlaste se k odběru našeho newsletteru a získejte nejnovější informace o kybernetické bezpečnosti přímo do vaší e-mailové schránky.

Vaše údaje jsou v bezpečí. Newsletter můžete kdykoliv odhlásit.