GlobIterator::__construct
(PHP 5 >= 5.3.0)
GlobIterator::__construct — Construit un itérateur de type glob
Description
public GlobIterator::__construct
( string
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO
] )Construit un itérateur de type glob.
Liste de paramètres
-
path -
Le chemin du dossier.
-
flags -
Les options, qui peuvent être un champ de bits de constantes de classe FilesystemIterator.
Exemples
Exemple #1 Exemple avec GlobIterator
<?php
$iterator = new GlobIterator('*.dll', FilesystemIterator::KEY_AS_FILENAME);
if (!$iterator->count()) {
echo 'No matches';
} else {
$n = 0;
printf("Matched %d item(s)\r\n", $iterator->count());
foreach ($iterator as $item) {
printf("[%d] %s\r\n", ++$n, $iterator->key());
}
}
?>L'exemple ci-dessus va afficher quelque chose de similaire à :
Matched 2 item(s) [1] php5ts.dll [2] php_gd2.dll
Voir aussi
- DirectoryIterator::__construct() - Construit un nouvel itérateur de dossier à partir d'un chemin
- GlobIterator::count() - Lit le nombre de dossiers et fichiers
- glob() - Recherche des chemins qui vérifient un masque
