Replace \n with '' by using str_replace() in PHP -


i have following code

$s = '\n test@gmail.com \n '; $s = str_replace('\n', '', $s);  echo $s; 

i want replace '\n' char '' it's not working above code. have found \n new line char ascii value 10 echo ord(substr($s, 0, 1)); not working. it's not clear me exact reason behind not working above code. please help.

you need place \n in double quotes. inside single quotes treated 2 characters '\' followed 'n'

try below code:

$s = "\n test@gmail.com \n"; $s = str_replace("\n", '', $s);  echo $s; 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -