更新时间:2023-02-23 18:55:26
这应该对您有用:
(在这里,我首先使用*.csv的所有文件. > glob()
.此后,我循环浏览每个文件,并使用 fopen()
和 fgetcsv()
.)
(Here I first grab all files out of the directory which have the extension *.csv
with glob()
. After this I loop through each file and read it with fopen()
and fgetcsv()
.)
<?php
$files = glob("$PathToCreate$version/*.csv");
foreach($files as $file) {
if (($handle = fopen($file, "r")) !== FALSE) {
echo "<b>Filename: " . basename($file) . "</b><br><br>";
while (($data = fgetcsv($handle, 4096, ",")) !== FALSE) {
echo implode("\t", $data);
}
echo "<br>";
fclose($handle);
} else {
echo "Could not open file: " . $file;
}
}
?>