Jump to content


Photo

<pre> tags with readfile()

pre readfile preformatted

  • Please log in to reply
2 replies to this topic

#1 zimbabweo

zimbabweo

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 March 2013 - 07:49 PM

I can't figure out how to combine readfile() with <pre> tags so that the \n linebreaks in my text file are displayed properly.

 

// works but doesn't print line breaks
echo readfile("filename.txt");

 

// doesn't work -- parse error

echo "<pre>readfile("filename.txt")</pre>";

 

// doesn't work -- parse error
echo "<pre>{readfile("filename.txt")}</pre>\n";

 

Any tips to solve this?



#2 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 14,135 posts
  • LocationCheshire, UK

Posted 10 March 2013 - 08:00 PM

echo '<pre>';
readfile('filename.txt');
echo '</pre>';
 

 

or

 

echo nl2br(file_get_contents('filename.txt'));

Edited by Barand, 10 March 2013 - 08:11 PM.

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#3 zimbabweo

zimbabweo

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 March 2013 - 08:05 PM

Barand, that works perfectly!! Many thanks.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com