Reading a CSV File in PHP

Source code :


<?php
$file = fopen("test.csv","r");

echo "<pre>";
while(! feof($file))
print_r(fgetcsv($file));
echo "<pre>";

fclose($file);
?>

Output :

Array
(
    [0] =&gt; 1
    [1] =&gt; Dennis Ritchie
    [2] =&gt; Father of C
)
Array
(
    [0] =&gt; 2
    [1] =&gt; Steve Jobs
    [2] =&gt; Founder of Apple
)
Array
(
    [0] =&gt; 2
    [1] =&gt; Bill Gates
    [2] =&gt; Founder of Microsoft
)

Notes :

Here is the CSV file

1,'Dennis Ritchie','Father of C'
2,'Steve Jobs','Founder of Apple'
2,'Bill Gates','Founder of Microsoft'

Output :


                

Comments :