faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 29 people (52%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I use PHP to "print" data on an HTML page from a comma delimited text file?

Mar 15th, 2008 17:55
ha mo, Lee Forkenbrock, K L, php.net


This is probably the easiest way, using the explode function.
Explode takes a string and splits it into an array based on a
given delimeter, in your case a ",".
$fp = fopen("file", "r");
while(!feof($fp)) {
     $string = fgets($fp);
     $array_str = explode(",", "$array_str"); //explode line
     for($i=0; $i<count($array_str); $i++) //go through each new string
     {
        echo $array_str[$i]; //format as you wish
        echo "<br>"
     }
}
fclose($fp);
That should do it, I hope I didn't leave anything out...Good Luck
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.mozmar.com
http://www.yamot.com
http://www.templatestemp.com