PDA

View Full Version : Newline and Tab in PHP


BigR
11-08-04, 08:10
Is there a way to sent a new line (i.e. \n) and tab (i.e. \t) in php???

i am trying to format some output that i get and i need to be able to place returns and tabs into it

thanks

Wookie
11-08-04, 10:31
http://www.wellho.net/regex/php.html


I just use html codes such as <br>


IE:
echo "<br>";

goldfish
11-08-04, 13:13
There's a function to convert newlines to <br />'s in php already.


nl2br($string);

http://uk.php.net/manual/en/function.nl2br.php

See also :
htmlspecialchars(); (http://uk.php.net/manual/en/function.htmlspecialchars.php)
htmlentities(); (http://uk.php.net/manual/en/function.htmlentities.php)
wordwrap(); (http://uk.php.net/manual/en/function.wordwrap.php)

As for usage, I'd put these on the output (i.e. input from the DB, output to the page) rather than cluttering the DB up with hundreds of <br />'s and &amp;'s