PHP replace string after using file_get_contents

后端 未结 2 1453
别跟我提以往
别跟我提以往 2021-01-25 18:53

Hi I am looking to replace words in an html email I am loading via file_get_contents

Here is my code:



        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-25 19:05

    You shouldn't use regular expressions for this; it's simple string replacement:

    $message = strtr($message, array(
        '$SAD' => 'HAPPY',
    ));
    

    Btw, if you use "$SAD" for the search string, PHP will try to evaluate a variable called $SAD, which doesn't exist and will throw a notice if your error_reporting is configured to show it.

提交回复
热议问题