What PHP function can be used to convert newline characters to HTML line breaks?
To convert newline characters to HTML line breaks in PHP, you can use the nl2br() function. This function takes a string as input and replaces newline characters (\n) with the HTML <br> tag. This is useful when you want to display text that contains newline characters in HTML format.
$text_with_newlines = "Hello\nWorld!";
$text_with_html_line_breaks = nl2br($text_with_newlines);
echo $text_with_html_line_breaks;