龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

glob php中glob函数使用范例

时间:2014-06-17 15:28来源:网络整理 作者:网络 点击:
分享到:
php中glob函数使用范例 [代码片段(43行)]
$dir = './';

foreach(glob($dir.'*.txt') as $file) {
    print $file . "\n";
}

/* returns: 

./dummy.txt
./foo.txt
./ideas.txt
./robots.txt
./scite.txt

*/

/*
** other examples:
*/

// also possible:
$files = glob('*.*');
sort($files);

// This shows how to use the GLOB_BRACE flag:
$images = glob("images/{*.jpg,*.gif,*.png}", GLOB_BRACE);
print_r($images);

/* Valid flags:

GLOB_MARK
GLOB_NOSORT
GLOB_NOCHECK
GLOB_NOESCAPE
GLOB_BRACE
GLOB_ONLYDIR
GLOB_ERR

see PHP.net manual for more info
*/
精彩图集

赞助商链接