Using fgetscsv function

Using fgetscsv function

Reading the data saved in CSV file format

fgetcsv -- Gets line from file pointer and parse for CSV fields

Fgetcsv() example - Read and print entire contents of a CSV file
The field delimiter is assumed to be a comma, unless you specify another delimiter with the optional third parameter.

PHP Code

<?php
 
$fp = fopen('csvfile.txt','r');
while($line = fgetcsv($fp,'1024',',')){
echo "<pre>";
print_r($line);
echo "</pre>";
 
/*
foreach($line as $value){
echo "$value<br>";
}
echo "<hr>";
*/
}
?>

See PHP: fgetcsv - Manual for more information.

Take a look at the contents of csvfile.txt

See it in action. ¦ Get complete code