I am trying to strip newlines and carriage returns from form data input from a text field. I have tried various methods but all seem to be failing.
I am set up on a windows box could this be an issue?
I have tried:
Code: Select all
$string = ereg_replace("/\n\r|\r\n|\n|\r/", " ", $string)
$string = preg_replace("/\t/", " ", $string);I have tried stripping them before entry into the database and also after retrieval. But nothing seems to be working.
From the above when echoing the string it seems to place everything on one line but also replaces the spaces with the \r\n characters
i.e. some text\r\n\r\nmore text\r\nmore text\r\n\r\n\r\nmore text
I also tried switching the replace string with the replacing space and still same results!
Any assistance appreciated.
Cheers