php搜尋目前目錄所有檔案,程式碼如下:
$array = glob('*.*');
print_r($array );
[0] => 1.php [1] => 10.php [2] => 11.php => 3.asp
[5] => 4.aspx
[6] => 5.html
[7] => 6.php > 8.php
[10] => 9.php
)
*/
搜尋以.php結果的php檔案,程式碼如下:
$array = glob('*.php');
$array = glob('*.php'); /* Array ( [0] => 1.php1.php
[3] => 6.php
[4] => 7.php
[5] => 8.php
搜尋包括有php,aspx 檔案,程式碼如下:
$files = glob('*.{php,aspx}', GLOB_BRACE);
print_r( $files );
] => 1.php [1] => 10.php [2] => 11.php [3] => 6.php [5] => 8.php [6] => 9.php [7] => 4.aspx ) */ 在指定目錄搜尋以1開立的php檔案15/1*.php'); print_r($files); /*1.php
[1] => ../05-15/10.php
[2] => ../05-15/11.php
)
*/
$files = array_map('realpath',$files);
print_r($files);
si.com -15 . php [1] => D:wwwwww.phpfensi.com-15 .php [2] => D:wwwwww.phpfensi.com-15 [2] => D:wwwwww.phpfensi.com-15 [2] => D:wwwwww.phpfensi.com-15 .事比scandir() 函數更強大,可以按照某種模式搜尋文件.