Skip first line of fgetcsv method

后端 未结 6 603
长发绾君心
长发绾君心 2020-11-28 12:25

I have a CSV file and I read data from CSV file then I want to skip first line of CSV file.Which\'ll contain any header. I am using this code.

while (($emapDa         


        
6条回答
  •  暖寄归人
    2020-11-28 13:07

    Before beginning the while loop, just get the first line and do nothing with it. This way the logic to test if it's the first line is not needed.

    fgetcsv($file, 10000, ",");
    while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) {
      //....
    }
    

提交回复
热议问题