讀取CSV文件:
$file = fopen('data.csv', 'r');
while (($data = fgetcsv($file)) !== false) {
print_r($data);
}
fclose($file);
寫入CSV文件:
$data = [
['John', 'Doe', 'john.doe@example.com'],
['Jane', 'Smith', 'jane.smith@example.com'],
];
$file = fopen('data.csv', 'w');
foreach ($data as $row) {
fputcsv($file, $row);
}
fclose($file);