glob() 関数は、指定したパターンに一致するファイル名またはディレクトリの配列を返します。
この関数は、ファイル/ディレクトリの配列を返します。失敗した場合はFALSEを返します。
glob(pattern,flags)
パラメータ | 説明 |
---|---|
pattern | 必須。検索するパターンを指定する |
flags | 任意。特別な設定を指定する。 指定可能な値:
|
<?php
print_r(glob("*.txt"));
?>
上のコードの出力は次の様になります:
Array
(
[0] => target.txt
[1] => source.txt
[2] => test.txt
[3] => test2.txt
)
<?php
print_r(glob("*.*"));
?>
上のコードの出力は次の様になります:
Array
(
[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
)