What alternative PHP function can be used to replace unwanted characters like "\r\n" in a string?
Unwanted characters like "\r\n" in a string can be replaced using the PHP function `str_replace()`. This function allows you to search for a specific substring in a string and replace it with another substring. By using `str_replace()` with the unwanted characters as the search string and an empty string as the replacement, you can effectively remove those unwanted characters from the string.
$string = "This is a string with \r\n unwanted characters";
$cleaned_string = str_replace("\r\n", "", $string);
echo $cleaned_string;