How can you enable automatic line breaks in a textarea in PHP?

To enable automatic line breaks in a textarea in PHP, you can use the nl2br() function to convert newlines (\n) to HTML line breaks (<br>). This will ensure that line breaks entered by the user in the textarea are displayed correctly when the text is outputted.

&lt;?php
$text = $_POST[&#039;textarea_input&#039;]; // Get the text from the textarea input
$text_with_line_breaks = nl2br($text); // Convert newlines to HTML line breaks
echo $text_with_line_breaks; // Output the text with line breaks
?&gt;