← All built-ins / nl2br()

nl2br()

nl2br(string $s): string

Parameters

NameTypeDescription
$sstringinput string with newlines

Return value

The string with "<br />" inserted before every newline (newlines kept).

Example

echo nl2br("line1\nline2"), "
";
line1<br />
line2

See also

htmlspecialchars()