php8.5
Home/ Manual/ spl / splfixedarray/ SplFixedArray::count

SplFixedArray::count

PHP function Edit on GitHub ✎

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Returns the size of the array

Description

SplFixedArray::count(): int

Returns the size of the array.

Parameters Parameters

Return Values

Returns the size of the array.

Examples

SplFixedArray::count example

php
<?php
$array = new SplFixedArray(5);
echo $array->count() . "\n";
echo count($array) . "\n";
?>

The above example will output:

output
5
5

Notes

Note

This method is functionally equivalent to SplFixedArray::getSize.

Note

The count of elements is always equal to the set size because all values are initially initialized with null.

See Also

  • SplFixedArray::getSize

Source: reference/spl/splfixedarray/count.xml · from the official PHP manual (php/doc-en)