相关疑难解决方法(0)

preg_replace导致美元符号被删除

我有一个电子邮件系统,用户在那里写一条消息并发送消息.我刚发现的主要问题是考虑这个代码

    $findEmail = $this->Data->field('body', array('id' => 1610));

    //$getUserEmailTemplate will take frm dbase and e.g: 
    //Hi, @@MESSAGE@@. From: StackOverflow
    //It should change @@MESSAGE@@ part to data from $findEmail (in this example is the $74.97 ...)

    $getUserEmailTemplate = $findUser['User']['email_template'];
    $emailMessage = preg_replace('/\B@@MESSAGE@@\B/u', $findEmail, $getUserEmailTemplate);

    debug($findEmail);
    debug($emailMessage);
Run Code Online (Sandbox Code Playgroud)

并考虑$ findemail结果的电子邮件的此输入:

$74.97
$735.00s
Run Code Online (Sandbox Code Playgroud)

$ email消息将导致:

.97
5.00s
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?我觉得我的preg_replace模式存在问题.

用户模板可以是任何东西,只要有@@ MESSAGE @@,该部分将被更改为用户消息输入.

谢谢

php regex string cakephp preg-replace

7
推荐指数
2
解决办法
2014
查看次数

标签 统计

cakephp ×1

php ×1

preg-replace ×1

regex ×1

string ×1