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 -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -