Table of Contents

Syntax

string nl2br(string $text [, bool $use_xhtml_tags = true])

(PHP 4, PHP 5)

$text The source string to convert.
$use_xhtml_tags Should we use XHTML break tags (<br/>) or normal HTML tags (<br>).
RETURNS The source string with breaks inserted before all newlines.

What it Does

Inserts an XHTML (or HTML) break element before all newlines in the source string.

Example

// insert break elements for each line break in the source
$html = nl2br("One\nTwo\nThree");
echo $html;