PHP glob()Fonctions
Manuel de référence complet sur le système de fichiers PHP
Définition et utilisation
La fonction glob() renvoie un tableau contenant les noms de fichiers ou répertoires correspondant au motif spécifié.
Cette fonction renvoie un tableau contenant les fichiers/répertoires correspondants. En cas d'échec, elle renvoie FALSE.
Syntaxe
glob(pattern,flags)
| Paramètre | Description |
|---|---|
| pattern | Obligatoire. Spécifie le motif de recherche. |
| indicateurs | Facultatif. Spécifie des paramètres spéciaux. Valeurs possibles :
|
Exemple 1
<?php
print_r(glob("*.txt"));
?>
print_r(glob("*.txt"));
?>
Le code ci-dessus affichera :
Tableau
(
[0] => target.txt
[1] => source.txt
[2] => test.txt
[3] => test2.txt
)
(
[0] => target.txt
[1] => source.txt
[2] => test.txt
[3] => test2.txt
)
Exemple 2
<?php
print_r(glob("*.*"));
?>
print_r(glob("*.*"));
?>
Le code ci-dessus affichera :
Tableau
(
[0] => contacts.csv
[1] => default.php
[2] => target.txt
[3] => source.txt
[4] => tem1.tmp
[5] => test.htm
[6] => test.ini
[7] => test.php
[8] => test.txt
[9] => test2.txt
)
(
[0] => contacts.csv
[1] => default.php
[2] => target.txt
[3] => source.txt
[4] => tem1.tmp
[5] => test.htm
[6] => test.ini
[7] => test.php
[8] => test.txt
[9] => test2.txt
)
Manuel de référence complet sur le système de fichiers PHP Autres extensions