I've tried about everything to delete some extra
characters in a web application I'm working with. I was hoping someone has encountered this issue before and knows what can be causing this. All my JS and PHP files are UTF-8 encoded with no BOM.
And yes I've tried things like
In JS:
text.replace(/
/g,"")
In PHP:
preg_replace("[
]","",$result);
str_replace("
","",$result);
and when I try
text.replace(/
/g,"")
in the firebug console using the same string I get from the server it works but for reason it doesn't work in a JS file.
I'm desperate, picky and this is killing me. Any input is appreciated.
EDIT:
If it helps, I know how to use the replace functions above. I'm able to replace any other string or pattern except
for some reason.
Answer Explanation:
Some people do and use what works because it just works. If you are like me and for the record I always like to know why what works WORKS!
In my case:
Why this works? str_replace('
', '', $result)
And this doesn't? str_replace("
", '', $result)
Looks identical right?
Well it seems that when you enclose a string with a character value like
in double quotes "
"
it's seen as it's character value NOT as a string. On the other hand if you enclose it in single quotes '
'
it's really seen as the string
. At least that is what i concluded in my 3 hours headache.
If what I concluded is a setup specific issue OR is erroneous please do let me know or edit.