I'm trying to Read a CSV file, where the format is:
titleA,titleB,titleC
data1A,data1B,data1C
data2A,data2B,data3C
The OUTPUT expected is:
Array
(
[0] => Array
(
[titleA] => data1A
[titleB] => data1B
[titleC] => data1C
)
[1] => Array
(
[titleA] => data2A
[titleB] => data2B
[titleC] => data2C
)
I tried using something that I foound here:
if (($handle = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$twoDarray[] = $data;
}
fclose($handle);
}
But it shows 1 array with all the titles and other 2 Arrays with Data.