What is the common issue with line breaks not displaying properly when retrieving text from a database using PHP?

When retrieving text from a database using PHP, the common issue with line breaks not displaying properly is due to the difference in line break characters between the database and the HTML output. To solve this issue, you can use the PHP function nl2br() to convert newline characters (\n) to HTML line breaks (<br>).

// Retrieve text from the database
$text = &quot;This is a text with line breaks\nthat need to be displayed properly.&quot;;

// Convert newline characters to HTML line breaks
$text_with_line_breaks = nl2br($text);

// Output the text with line breaks
echo $text_with_line_breaks;