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?

60 of 76 people (79%) answered Yes
Recently 7 of 10 people (70%) answered Yes


When i include a txt file the html page ignores the end of lines. And i get one long line with text. I would have multiple lines with hard breaks.
Why is fread adding in the escape codes to a txt file that I am echo'ing
In the following script, how do I get hard line breaks? $GrabURL = "http://www.geocities.com/michael

Apr 2nd, 2008 20:52
dman, ha mo, Alder Rus, Philip Olson, Todor Gaidarov, Rini Setiadarma, kees brown, Jeremy Fulton, Walt Disney, http://www.ttnr.org

Try this :
  $file = 'info.txt';
  $fp   = fopen($file,'r');
  $info = fread($fp, filesize($file));
$info is now the contents (a string) of the file info.txt.  To convert 
linebreaks (\n) to <br>'s in a string, let's use the PHP nl2br() 
function :
  $info = nl2br($info):
Now each linebreaks will be <br>'s.
Also note that such linebreaks show up in browser in <pre></pre>, 
perhaps this faqt will be of use too :