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
Post a Comment