Reading csv. How to convert array from numeric keys?
PHP Code:
$keys = array('name', 'address');
handle = fopen("data.csv", "r") ;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// ?
}
What is the most efficient way of turning a sample data.csv file such as this:
Code:
name, address
"C Stunt", "Letsby Avenue"
"Ishood Coco", "Arfway house"
into an associated array such as
Code:
$arr[0]['name'] = "C Stunt" ;
$arr[0]['address'] = "Letsby Avenue" ;
$arr[1]['name'] = "Ishood Coco" ;
$arr[1]['address'] = "Arfway house" ;
Naturally the real csv file has many more columns than this, I just wondered if there was an easy way of doing it, rather than re-assigning the values by hand?