nl2br

(PHP 3, PHP 4 , PHP 5)

nl2br --  Insere quebras de linha HTML antes de todas newlines em uma string

Descrição

string nl2br ( string string )

Retorna string com '<br />' inserido antes de todas as newlines.

Nota: Começa no PHP 4.0.5, nl2br() está agora em XHTML complacente. Todas as versões anteriores a 4.0.5 retornarão string com '<br>' inserido antes das newlines ao invés de '<br />'.

Exemplo 1. usando nl2br()

<?php
echo nl2br("foo isn't\n bar");
?>

isto irá mostrar :

foo isn't<br />
 bar

Veja também htmlspecialchars(), htmlentities(), wordwrap() e str_replace().