fgetcsv函數用于逐行讀取CSV文件中的數據,并將其轉換為數組。其語法如下:
fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\" ]]]] ) : array|false
參數說明:
返回值:
示例:
$handle = fopen("data.csv", "r");
while (($data = fgetcsv($handle)) !== false) {
// 處理每一行數據
print_r($data);
}
fclose($handle);