Jump to content
Larry Ullman's Book Forums

Str_Replace(Array("\r", "\n"), ' ', $Value) Won't Recognize The \r And \n In A String


Recommended Posts

I've found that in order for the following line of code from script 13.1 - email.php to work

 

$value = str_replace(array("\r", "\n", "%0a", "%0d"), ' ', $value);

 

the \r and \n should be escaped like so:

 

$value = str_replace(array("\\r", "\\n", "%0a", "%0d"), ' ', $value);

 

Otherwise they won't be replaced.

Link to comment
Share on other sites

 Share

×
×
  • Create New...