post icon

How to read CSV (Comma Separated Files) line by line in PHP?

CSV is plain text file, which means you can open it notepad or anyother text editor.
CSV file stores tabular data (numbers and text) in plain-text form.

$file_handle = fopen(“csv_file_name.csv”, “r”);

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

print $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . “
“;

}

fclose($file_handle);

Comments are closed.

Leave a comment