Can someone explain why, in this situation, scandir is getting my directory, but the glob is getting...well, it seems like it's getting the path:
$directory = "../../../XXXXXXXXXXXXXX/media/csv";
With scandir:
$files = scandir($directory);
print_r($files);
Result:
Array ( [0] => . [1] => .. [2] => myCsv.csv [3] => index.html )
With Glob:
$files = glob($directory . "*"); # i wanted to select only CSV, but it returned empty. so i placed a *.
Result:
Array ( [0] => ../../../XXXXXXXXXXXXXX/media/csv )
由于您的$directory
类似于../XXX/media/csv
,您需要将其附加到/*.csv
以便它将成为../XXX/media/csv/*.csv
(目前它是../XXX/media/csv*
)。
$files = glob($directory . "/*.csv");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.