CKTIS / PHP
sizeof()
Dieser Alias von count liefert die Zahl der Arrayelemente oder den Wert eines Countable-Objekts.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
sizeof(Countable|array $value, int $mode = COUNT_NORMAL): intDieser Alias von count liefert die Zahl der Arrayelemente oder den Wert eines Countable-Objekts. COUNT_RECURSIVE zählt verschachtelte Elemente samt ihren Containern. Es ist keine Bytezahl. Ein String löst in PHP 8 TypeError aus.
Signatur
sizeof(Countable|array $value, int $mode = COUNT_NORMAL): int
Ausgabe des Beispiels
[2,4,1]
Beispiele
<?php
$rows = ["a"=>[1,2],"b"=>[]];
echo json_encode([sizeof($rows),sizeof($rows,COUNT_RECURSIVE),sizeof(new ArrayObject([9]))]);
Ergebnis
[2,4,1]