PHP Read CSV to Array


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function read_csv_file($file) {
  2. $file = fopen($file, 'r');
  3. $csv = array();
  4.  
  5. while (($line = fgetcsv($file)) !== FALSE) {
  6. $csv[] = $line;
  7. }
  8.  
  9. fclose($file);
  10. return $csv;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.