Skip first line of fgetcsv method

后端 未结 6 594
长发绾君心
长发绾君心 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:16

    A bit late, but here is another way to do so (without having to count all the lines): with fgets

    $file = fopen($filename, 'r');  // create handler
    fgets($file);  // read one line for nothing (skip header)
    while (($line = fgetcsv($file, 10000, ",")) !== FALSE) {
        // do your thing
    }
    

    One might consider this to be more elegant

提交回复
热议问题