What is the best PHP function to remove line breaks from a string variable?

To remove line breaks from a string variable in PHP, you can use the `str_replace()` function. This function allows you to replace specific characters in a string with another character, effectively removing line breaks. Simply use `str_replace("\n", "", $string)` to remove line breaks from the string variable.

$string = "Hello\nWorld!";
$clean_string = str_replace("\n", "", $string);
echo $clean_string;