We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


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 

You need to login to post a comment.