ejaboneta Posted October 8, 2009 Share Posted October 8, 2009 The first line of each csv I upload goes missing! Anyone know why? <?php $row = 0; $handle = fopen("$file", "r"); $data = fgetcsv($handle, 1000, ","); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $newvalues[firstname] = $data[0]; $newvalues[lastname] = $data[1]; $newvalues[birthday] = $data[3]; $newvalues[address] = $data[4]; $newvalues[city] = $data[5]; $newvalues[state] = $data[6]; $newvalues[zip] = $data[7]; $newvalues[phone] = $data[9]; $newvalues[sex] = $data[11]; $row++; echo "<br>"; $fdf_file=time(). rand(0,100) . '.fdf'; $fdf_dir=dirname(__FILE__).'/results'; $pdf_doc='Cigna.pdf'; $fdf_data=createFDF('Cigna.pdf',$newvalues); if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){ fwrite($fp,$fdf_data,strlen($fdf_data)); echo $fdf_file,' written successfully.'; }else{ die('Unable to create file: '.$fdf_dir.'/'.$fdf_file); } } fclose($handle); ?> Quote Link to comment https://forums.phpfreaks.com/topic/177029-fgetcsv-missing-first-line/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 9, 2009 Share Posted October 9, 2009 $data = fgetcsv($handle, 1000, ","); Yes, the above line of code, right after the fopen() statement is reading and discarding the first line from the file. Why do you have that in your code? Quote Link to comment https://forums.phpfreaks.com/topic/177029-fgetcsv-missing-first-line/#findComment-933433 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.