找到电子邮件并用PHP中的句子替换

时间:2011-07-16 21:20:15

标签: str-replace

如何通过将电子邮件替换为某些字词来阻止人们在说明字段中输入其电子邮件地址,例如,如果用户输入了以下文字:

Please contact me via joe.joey@email.com.

我希望输出为:

Please contact me via <email address is blocked>.

我知道一个基本的str_replace,但输出只是:

//output is Please contact me via joe.joey <email address is blocked> email.com
  $string = 'Please contact me via joe.joey@email.com.';
  $lookfor = '@'; 
  $replacewith = '<email address is blocked>';      
  $newstring = str_replace($lookfor, $replacewith, $string);

感谢。

1 个答案:

答案 0 :(得分:1)