nl2br Inserts HTML line breaks before all newlines in a string Description stringnl2br stringstring Returns string with '<br />' inserted before all newlines. Starting with PHP 4.0.5, nl2br is now XHTML compliant. All versions before 4.0.5 will return string with '<br>' inserted before newlines instead of '<br />'. using <function>nl2br</function> ]]> this will output : bar ]]> See also htmlspecialchars, htmlentities, wordwrap, and str_replace.