parse csv help

I have a script that generates multiple product configuration for ecommerce store input.
It works fine at the moment but I want it to output the header row as is and then move on to the next rows and begin creating the configuration as normal. Also I would like the script to output a csv file for me as well. Here is my code…

<?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 500000, ",")) !== FALSE) { $num = 1; echo $data[0] . "," . $data[1] . "," . $data[2] . "
\n"; $row++; for ($c=0; $c < $num; $c++) { echo "admin" . ",". "base" . "," .$data[2] . "-Small-Satin-No Frame" . ",". "25.00" . ",". "Image Options" . "," . "simple" . ",".$data[6] . "," . "0" . "," .$data[8] . "-Small-Satin-No Frame" ."," . $data[9] . "," .$data[10]. "," .$data[11]. "," . $data[12] . "," .$data[13]. "," .$data[14]. "," .$data[15]. "," .$data[16] . "," . "No Layout Updates" . "," . "Product Info Column" . "," . "No". "," .$data[20]. "," .$data[21]. "," . ".9" . "," . "Enabled". "," . "None". "," . "No". "," . "1". "," . "Yes". "," . "No". "," . "Small" . "," . "Satin" . "," . "No Frame" . "," .$data[32]. "," .$data[33]. "," .$data[34]. "," .$data[35]. "," .$data[36]. "," .$data[37]. "," .$data[38]. "," .$data[39]. "," .$data[40]. "," .$data[41]. "," .$data[42]. "," . "9999". "," . "0". "," . "1". "," . "0". "," . "0". "," . "1". "," . "1". "," . "1". "," . "0". "," . "1". "," . "1". "," .$data[54]. "," .$data[55]. "," . "1". "," . "0". "," . "1". "," . "0". "," . "1". "," . "0". "," . "1". "," . "0". "," .$data[64]. "-Small-Satin-No Frame" . "," . "0". "," . "simple" . "," .$data[67] . "," .$data[68]. "," .$data[69]. "," .$data[70]. "," .$data[71]. "," .$data[72]. "
\n"; } } fclose($handle); } ?>

any help would be greatly appreciated. Thanks in advance.

Sponsor our Newsletter | Privacy Policy | Terms of Service