Home / PHP Tips Generated By ChatGPT / Replacing Line Breaks with HTML Breaks in PHP Convert line breaks in a string to HTML elements with nl2br(). Source Code $text = "This isna stringnwith line breaks."; echo nl2br($text);