Monday, March 2, 2020

How to output text file with line breaks in PHP?

To convert the plain text line breaks to html line breaks, try this:

$fh = fopen("filename.txt", 'r');
$pageText = fread($fh, 25000);
echo nl2br($pageText);

Note: the nl2br function wraps the text.

No comments:

Post a Comment