假设有一个名为的文件夹example,其中有一些csv文件,例如(a.csv, b.csv....).
该test.php目录与example文件夹相同.现在我想将所有csv文件名传递给以下if条件.即,替换test.csv所有的csv文件名
if (($handle = fopen("test.csv", "r"))
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我使用以下代码:
$files= glob("./example/*.csv");
if (($handle = fopen("$files", "r"))
Run Code Online (Sandbox Code Playgroud)
但它不起作用.谢谢.
xda*_*azz 12
$files 是一个数组,你需要循环它.
$files = glob("./example/*.csv");
foreach($files as $filepath) {
if ($handle = fopen($filepath, "r")) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)