Are there any specific PHP functions or methods that can be used to handle line breaks in text input?

When handling text input in PHP, line breaks can sometimes cause formatting issues. To handle line breaks in text input, you can use the PHP function nl2br() which converts newlines to HTML line breaks. This function can be used to ensure that line breaks are properly displayed in HTML output.

$text_input = "This is a text with line breaks.\nLine 1\nLine 2";
$processed_text = nl2br($text_input);

echo $processed_text;