<?php
$csvPath = 'test.csv';
$handle = fopen($csvPath, 'r');
if ($handle === false) {
throw new \Exception("fopen [{$csvPath}] fail");
}
$i = 0;
while (($data = fgetcsv($handle)) !== false) {
// 跳过第一行的表头
if ($i == 0) {
$i++;
continue;
}
var_dump($data);
}
[PHP]读取CSV文件
于 2022-05-26 11:01:04 首次发布