How can the issue of line breaks being included in the textarea input be resolved in PHP?

When dealing with textarea input in PHP, line breaks are often included in the input data, which can cause formatting issues or unexpected behavior when displaying or processing the text. To resolve this issue, you can use the PHP function `nl2br()` to convert line breaks to HTML line breaks `<br>` tags before displaying the text.

&lt;?php
// Get textarea input data
$text = $_POST[&#039;textarea_input&#039;];

// Convert line breaks to HTML line breaks
$formatted_text = nl2br($text);

// Display the formatted text
echo $formatted_text;
?&gt;