[英]how to get all the csv file name under a directory?
假設有一個名為example
的文件夾,其中有一些csv文件,例如(a.csv, b.csv....
)。
test.php
目錄與example
文件夾相同。 現在我想將所有csv文件名傳遞給以下if條件。 即,將test.csv
替換為所有csv文件名
if (($handle = fopen("test.csv", "r"))
我該怎么辦?
我使用以下代碼:
$files= glob("./example/*.csv");
if (($handle = fopen("$files", "r"))
但它不起作用。 謝謝。
$files
是一個數組,你需要循環它。
$files = glob("./example/*.csv");
foreach($files as $filepath) {
if ($handle = fopen($filepath, "r")) {
// ...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.