'\n' is two characters: a slash followed by the letter 'n'. Double-quoted strings allow escaping of special characters like tabs and newlines.
?> Using new line tags: Newline characters \n or \r\n can be used to create a new line inside the source code.
The strip_tags() function strips a string from HTML, XML, and PHP tags. Note: HTML comments are always stripped. This cannot be changed with the allow parameter. Note: This function is binary-safe.
Using str_replace() Method: The str_replace() method is used to remove all the special characters from the given string str by replacing these characters with the white space (” “).
str_replace(array("\r", "\n"), '', $string)
the pt2ph8 answer didn't work for me until I have changed it a little bit as follows:
str_replace(array("\\r", "\\n"), '', $string);
You can see the different results in this demo:
http://phpfiddle.org/lite/code/g5s8-nt3i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With