Forum und email

nl2br

(PHP 4, PHP 5)

nl2br — Indsætter HTML linieskift før alle nye linier i en streng

Beskrivelse

string nl2br ( string $string )

Returnere string med '<br />' indsat før alle nye linier.

Note: Fra PHP 4.0.5, overholder nl2br() XHTML standarden. Alle versioner før 4.0.5 vil returnere string med '<br>' indsat før nye linier, i stedet for '<br />'.

Example#1 Brug af nl2br()

<?php
echo nl2br("foo er ikke\n bar");
?>

Dette vil udskrive :

foo er ikke<br />
 bar

Se også htmlspecialchars(), htmlentities(), wordwrap(), og str_replace().