考虑这个文件结构:
/folder/locaux-S04_3.html
/folder/blurb.txt
/folder/locaux-S04_2.html
/folder/locaux-S05_1.html
/folder/tarata.02.jpg
/folder/locaux-S04_1.html
/folder/dfdsf.pdf
我需要检索名称包含目录中最高数值的文件。在上面的例子中,它是locaux-S05_1.html
我想出了 glob() 作为仅获取 locaux-S*.html 文件的有效方法,但我被困在下一步:找到文件名包含最高值的文件。
$files= glob(LOCAUX_FILE_PATH.'/locaux-S*.html');
foreach($files as $key=> $value){
// loop through and get the value in the filename. Highest wins a trip to download land!
$end = strrpos($value,'.');
$len= strlen($value);
$length = $len-$end;
$str = substr($value,8,$length);
// this gives me the meat, ex: 03_02. What next?
}
任何指针将不胜感激。