How can PHP be used to handle line breaks in <textarea> input?
When handling input from a <textarea> in PHP, line breaks are represented by the newline character (\n). To properly handle line breaks in <textarea> input, you can use the nl2br() function in PHP. This function converts newlines (\n) into HTML line breaks (<br>) so that the text is displayed correctly when outputted on a webpage.
<?php
// Retrieve the input from the <textarea>
$text = $_POST['textarea_input'];
// Convert newlines to HTML line breaks
$text_with_line_breaks = nl2br($text);
// Output the text with line breaks
echo $text_with_line_breaks;
?>