I have a .csv file. Some fields are empty and some fields have commas or dots.
Now how I could display it like this in array?
Array (
[0] => Name1,[email protected],13,56475,,190000,,,remit,5-Mar-15,26250
[1] => Name2,[email protected],11,11250,,22500,,,the bank,30-Apr-15,6250
[2] => Name3,[email protected],15,,,1500,receipt,,the market,7-Mar-15,1750
[3] =>Name4,[email protected],21,25500,,46750,receipt,,bank ,7-Mar-15,21350 ..... )
As of now I can only display it like this:
Array (
[0] => Name1
[1] => [email protected]
[2] => 13
[3] => 56475
[4] =>
[5] => 19000
[6] =>
[7] =>
[8] => remit
[9] => 5-Mar-15
[10] => 26250 )
Array (
[0] => Name2
[1] => [email protected]
[2] => 11
[3] => 11250
[4] =>
[5] => 22500
[6] =>
[7] =>
[8] => the bank
[9] => 30-Apr-15
[10] => 6250 ) ....
And I am using this code:
$file = fopen("pay.csv","r");
while(! feof($file))
{
echo '<pre>',print_r(fgetcsv($file)),'</pre>';
}
fclose($file);
I prefer using native csv functions.
fgetcsvor something like that coz some of my fields are empty and have commas.