What are common methods for removing line breaks in PHP strings, and what are the potential pitfalls associated with each method?

When working with strings in PHP, it is common to encounter line breaks that need to be removed for formatting purposes or data processing. Two common methods for removing line breaks in PHP strings are using the `str_replace` function and the `preg_replace` function. The `str_replace` function is simpler and faster but only removes exact matches, while the `preg_replace` function allows for more flexibility with regular expressions but may be slower for large strings.

// Using str_replace to remove line breaks
$string = "Hello\nWorld";
$clean_string = str_replace(array("\r", "\n"), '', $string);
echo $clean_string;

// Using preg_replace to remove line breaks
$string = "Hello\nWorld";
$clean_string = preg_replace("/\r|\n/", "", $string);
echo $clean_string;