Posted By

coggla on 01/20/08


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dhayes
tikitakfire


Files - Opening & Reading


 / Published in: PHP
 

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

  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
Posted By: dizzley on March 2, 2010

Streuth!

This code should read: fclose($read);

not fclose($textfile);

You need to login to post a comment.