PHP의 글로브 () 함수
정의 및 사용
() 함수는 배열을 포함하는 패턴이 지정된 파일 이름이나 디렉토리 글로브와 일치 반환합니다.
이 함수는 일치하는 파일 / 디렉토리의 배열을 반환합니다. 실패하면 FALSE를 반환합니다.
문법
glob(pattern,flags)
参数 | 描述 |
---|---|
pattern | 必需。规定检索模式。 |
flags | 可选。规定特殊的设定。 可能的值:
|
예 1
<?php
print_r(glob("*.txt"));
?>
print_r(glob("*.txt"));
?>
가 출력 위의 코드 :
Array
(
[0] => target.txt
[1] => source.txt
[2] => test.txt
[3] => test2.txt
)
(
[0] => target.txt
[1] => source.txt
[2] => test.txt
[3] => test2.txt
)
예 2
<?php
print_r(glob("*.*"));
?>
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
)
(
[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
)
PHP 파일 시스템 참조 설명서를 완료