Parsing a Tab Delimited File

This example code shows you how to parse a tab delimited file (or any other character delimited file for that matter), using PHP.
 1. <?php
 2. $FileName = "TabDelimitedFile.txt";
 3. $FileHandle = fopen($FileName,"r");
 4. $FileContent = fread ($FileHandle,filesize ($FileName));
 5. fclose($FileHandle);
 6. 
 7. // You can replace the \t with whichever delimiting character you are 
using
 8. $SplitContent = explode("\t", $FileContent);
 9. 
10. foreach($SplitContent as $CurrValue)

11. {

12.        echo $CurrValue."|";
13. }

14. ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top