通过 csv 文件的前两行

By pass the first two lines of csv file

我正在尝试使用 fgets 从 csv 文件中读取数据。但是,我想绕过前两行。

默认情况下,fgets 仅传递第一行。我怎样才能通过前两行来调整它呢?

$myfile = "/home/dibon/AML_Data/test.csv";
$myfile = fopen("$myfile", "r") or die("Unable to open file!");  

fgets($myfile); //First fgets to read over header line.

while($line=fgets($myfile)){
//Explode your line by space delimeter
$words=explode("|",$line);

DB::table('transaction_incremental')->insert(
['ReceiptNumber' => "$words[0]", 'InitiatingMSISDN' => "$words[2]"]
);

}
fgetcsv($handle); // get line 0 and move to next
fgetcsv($handle); // get line 1 and move to next
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    ....
}