php8.5
Home/ Manual/ spl / globiterator/ GlobIterator::count

GlobIterator::count

PHP function Edit on GitHub ✎

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

Get the number of directories and files

Description

GlobIterator::count(): int

Gets the number of directories and files found by the glob expression.

Parameters Parameters

Return Values

The number of returned directories and files, as an int.

Examples

GlobIterator::count example

php
<?php
$iterator = new GlobIterator('*.xml');

printf("Matched %d item(s)\r\n", $iterator->count());
?>

The above example will output something similar to:

output
Matched 8 item(s)

See Also

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