What are common methods to remove line breaks from text input in PHP?

When working with text input in PHP, it is common to encounter line breaks that can disrupt the formatting of the text. To remove line breaks from text input, you can use the PHP function `preg_replace()` with a regular expression pattern that matches line breaks. This will allow you to strip out any line breaks and ensure that the text is displayed without any unexpected formatting issues.

$text = "This is a text with
line breaks.";
$clean_text = preg_replace("/\r|\n/", "", $text);
echo $clean_text;