Thanks for your reply. Unfortunately, it did not help me. Let's say I have a textarea as follows submitted with a carriage return in it- <textarea name="text"></textarea> When receiving the POST, I want to identify and replace the carriage returns entered into the form. The following code does not work: $text=$_POST['text']; str_replace("\r", '', $text);, str_replace("\n", '', $text);, str_replace("\r\n", '', $text); The above functions do not remove the newlines. If instead I use $newline=" "; as the string to replace, it works!