What are the potential pitfalls of using str_replace to remove line breaks in PHP strings?
Using `str_replace` to remove line breaks in PHP strings can potentially remove legitimate line breaks within the content of the string. This can lead to unintended formatting issues or data corruption. To properly remove line breaks, it is recommended to use the `preg_replace` function with a regular expression pattern that specifically targets line breaks (\r, \n, or \r\n).
// Example code to remove line breaks using preg_replace
$string = "This is a string with line breaks\n";
$clean_string = preg_replace("/[\r\n]/", "", $string);
echo $clean_string;