Files - Opening & Reading


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

Open a comma delimited text file then read each line and break apart by delimiter


Copy this code and paste it in your HTML
  1. $read = fopen($textfile,"r");
  2. $file = fread($read,filesize($textfile));
  3. fclose($textfile);
  4.  
  5. $lines = explode ("\n", $file);
  6.  
  7. foreach ($lines as $line) {
  8. list($a,$b,$c,$d) = explode(',',$line);
  9. echo "$a $b $c $d";
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.