KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a text which might have different newline styles. I want to replace all newlines '\r\n', '\n','\r' with the same newline (in this case \r\n ). What's the fastest way to do this? My current solution looks like this which is way sucky: $sNicetext = str_replace("\r\n",'%%%%somthing%%%%', $sNicetext); $sNicetext = str_replace(array("\r","\n"),array("\r\n","\r\n"), $sNicetext); $sNicetext = str_replace('%%%%somthing%%%%',"\r\n", $sNicetext); Problem is that you can't do this with one replace because the \r\n will be duplicated to \r\n\r\n . Thank you for your help!
Tags (comma-separated)
Save Edits
Cancel