please delete me please delete me - 1 year ago 101
PHP Question

skip first line of fgetcsv method in php

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 (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
$sql = "INSERT into da1(contact_first, contact_last, contact_email) values('$emapData[0]','$emapData[1]','$emapData[2]')";


When i insert data into th database then header should not to be saved into the database.

Answer Source


$flag = true;
while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) {
   if($flag) { $flag = false; continue; }
   // rest of your code
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download