php explode didnot seem to work correctly in some cases
I finally realised that the error was occuring due to a field submitted in a form
Even though I was seeing a white space on screen, there were “
\r\n” in the string.
str_replace” and all is well again