0
我有这个readCSV函数,现在跳过第一行,但我需要它跳过三个第一行。在PHP中跳过3个CSV的第一行
实现该目标的首选方式是什么?
function readCSV($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle)) {
$array = fgetcsv($file_handle, 'r', ';');
$line_of_text[] = array('dato'=>$array[0],'vs'=>trim($array[1]),'vf'=>trim($array[2]));
}
fclose($file_handle);
return $line_of_text;
}
$csvFile = 'http://some.file.csv';
你可以称之为'与fgets($ file_handle)的循环之前'三倍。 –
保留一个计数器来计算循环内部处理的行数,只在计数器大于3时才动作。 – coderodour
Right @coderodour –