PHP CSV import Script
This is a simple code sample for reading any type of CSV file……
In the first line the CSV file contains the Header information.
like as fillows
File : test.csv
NUMBER,NAME 9895123456, Sharuk 9947123456, Salman
The csv file contains the mobile and name of customers.use the following code to read it.
<?php
$handle = fopen('test.csv', 'r');
if ($handle)
{
set_time_limit(0);
//the top line is the field names
$fields = fgetcsv($handle, 4096, ',');
//loop through one row at a time
while (($data = fgetcsv($handle, 4096, ',')) !== FALSE)
{
$data = array_combine($fields, $data);
}
fclose($handle);
}
?>




