我有這個劇本的工作,它(如果發現某事)返回找到文件的完整路徑。我需要它,只顯示它的子目錄。PHP文件搜索響應
舉例來說,如果它的發現,它會返回類似於:
./prls/carrier1/00000.prl
已在數據庫中!
我希望它只是說:carrier1。
$dirname = './prls/';
$findme = $_FILES["file"]["name"];
$dirs = glob($dirname.'*', GLOB_ONLYDIR);
$files = array();
//--- search through each folder for the file
//--- append results to $files
foreach($dirs as $d) {
$f = glob($d .'/'. $findme);
if(count($f)) {
$files = array_merge($files, $f);
}
}
if(count($files)) {
foreach($files as $f) {
echo $f . "<br />";
}
echo "Already in database!";
die;
} else {
echo "Nothing was found, continue..";//Tell the user nothing was found.
}
如果返回結果,我該如何顯示子目錄?
問題是什麼?你已經嘗試過了什麼? – kero