Friday, 15 July 2011

php - Ignore break line with str_replace -


The code below will replace some text, in fact I $ str from a text file < Code> file_get_contents , please imagine that there is a new line in $ str .

  $ str = 'From: My Name & lt; Myemail@myname.com> To: storm@yahoo.com Message-Id: & lt; 1638618225.203837.1426581391642.javaamamal Yahoo@mail.yahoo.com> '; $ Old = array ("my name", "to: storm@yahoo.com"); $ New = array ("new name", ""); Echo str_replace ($ old, $ new, $ str);  

Output:

 From : New name Message ID: & lt; 1638618225.203837.1426581391642.javaamamal Yahoo@mail.yahoo.com>  

Unfortunately, after deleting : storm@yahoo.com , the code will make a line break without creating a new break line how do i str_replace < Can I use / code>

As you said you get it from a text file and if you show that text file So, it is not creating a new line, it is actually not already removing the existing line.

  $ str = 'From: My name & lt; Myemail@myname.com> To: storm@yahoo.com Message-Id: & lt; 1638618225.203837.1426581391642.javaamamal Yahoo@mail.yahoo.com> '; $ Old = array ("my name", "to: storm@yahoo.com \ n"); $ New = array ("new name", "");  

No comments:

Post a Comment