Reputation: 33
I have a text file that I'm including on my page, however the carriage returns aren't there as they are in the text document. How can I keep them as they are in the text document?
Upvotes: 0
Views: 529
Reputation: 9215
Line breaks have no meaning in normal HTML (other than just being whitespace). You either need to convert them to HTML line breaks using nl2br()
, or put the content of the text file in a <pre></pre>
block.
Upvotes: 0
Reputation: 13586
$textfile = fopen('file.txt','r');
$readfile = fread($textfile);
echo nl2br($readfile);
Upvotes: 1