Here's the code that I'm using, but it doesn't output exactly what I want.
<?php
$file = fopen("ad.csv","r");
while(! feof($file))
{
print_r(fgetcsv($file));
}
fclose($file);
?>
Here's what it outputs currently:
Array ( [0] => cn [1] => mail [2] => telephonenumber [3] => uid ) Array ( [0] => [1] => [2] => [3] => ) Array ( [0] => admin [1] => [2] => [3] => ) Array ( [0] => Isaac Newton [1] => [email protected] [2] => [3] => newton ) Array ( [0] => Albert Einstein [1] => [email protected] [2] => 314-159-2653 [3] => einstein ) Array ( [0] => Nikola Tesla [1] => [email protected] [2] => [3] => tesla ) Array ( [0] => Galileo Galilei [1] => [email protected] [2] => [3] => galieleo ) Array ( [0] => Leonhard Euler [1] => [email protected] [2] => [3] => euler ) Array ( [0] => Carl Friedrich Gauss [1] => [email protected] [2] => [3] => gauss ) Array ( [0] => Bernhard Riemann [1] => [email protected] [2] => [3] => riemann ) Array ( [0] => Euclid [1] => [email protected] [2] => [3] => euclid ) Array ( [0] => Mathematicians [1] => [2] => [3] => ) Array ( [0] => Scientists [1] => [2] => [3] => ) Array ( [0] => read-only-admin [1] => [2] => [3] => ) Array ( [0] => Italians [1] => [2] => [3] => ) Array ( [0] => Test [1] => [2] => [3] => test ) Array ( [0] => Chemists [1] => [2] => [3] => ) Array ( [0] => Marie Curie [1] => [email protected] [2] => [3] => curie ) Array ( [0] => Alfred Nobel [1] => [email protected] [2] => [3] => nobel ) Array ( [0] => Robert Boyle [1] => [email protected] [2] => 999-867-5309 [3] => boyle ) Array ( [0] => Louis Pasteur [1] => [email protected] [2] => 602-214-4978 [3] => pasteur ) Array ( [0] => No Group [1] => [email protected] [2] => [3] => nogroup ) Array ( [0] => FS Training [1] => [email protected] [2] => 888-111-2222 [3] => training ) Array ( [0] => FS Training [1] => [email protected] [2] => 888-111-2222 [3] => jmacy )
In other words, it's almost as if it's adding all my CSV data into a multidimensional array...
What I want is to just output it as I see it like so:
cn,mail,telephonenumber,uid
,,,
admin,,,
"Isaac Newton",[email protected],,newton
"Albert Einstein",[email protected],314-159-2653,einstein
"Nikola Tesla",[email protected],,tesla
"Galileo Galilei",[email protected],,galieleo
"Leonhard Euler",[email protected],,euler
"Carl Friedrich Gauss",[email protected],,gauss
"Bernhard Riemann",[email protected],,riemann
Euclid,[email protected],,euclid
Mathematicians,,,
Scientists,,,
read-only-admin,,,
Italians,,,
Test,,,test
Chemists,,,
"Marie Curie",[email protected],,curie
"Alfred Nobel",[email protected],,nobel
"Robert Boyle",[email protected],999-867-5309,boyle
"Louis Pasteur",[email protected],602-214-4978,pasteur
"No Group",[email protected],,nogroup
"FS Training",[email protected],888-111-2222,training
"FS Training",[email protected],888-111-2222,jmacy