How can HTML and PHP be combined to create line breaks within a textarea for multiple lines of text?

To create line breaks within a textarea for multiple lines of text in HTML and PHP, you can use the PHP function nl2br() to convert newlines (\n) to HTML line breaks (<br>). This will allow users to input text with line breaks in a textarea and display it correctly on the webpage.

&lt;?php
if(isset($_POST[&#039;submit&#039;])){
    $text = nl2br($_POST[&#039;text&#039;]);
    echo $text;
}
?&gt;

&lt;form method=&quot;post&quot;&gt;
    &lt;textarea name=&quot;text&quot;&gt;&lt;/textarea&gt;
    &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;
&lt;/form&gt;