Text to HTML in PHP

848 Views Asked by At

nl2br(); can do for EOL but what about white spaces and/or tabs at the beginning(or not) of line? Is there any function to do this at once? I need well formatted html output of text file. Thx.

2

There are 2 best solutions below

1
On BEST ANSWER

well may be <pre>....</pre> can do it

also see

htmlspecialchars()

http://php.net/manual/en/function.htmlspecialchars.php

htmlentities()

http://www.php.net/manual/en/function.htmlentities.php

0
On

It is OK to use "pre" HTML tag.

<?php
echo '<pre>' ;
/// .... do text output stuff...
echo '</pre>' ;
?>

Sorry for my lame question. I'm new in WoW(word of web).