I have a mail system where the user writes a message and he sends a message. The main problem I just found, consider this code
$findEmail = $this->Data->field('body', array('id' => 1610)); //$getUserEmailTemplate will take frm dbase and eg: //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);
and consider this input for the email message for the result of $ findemail:
$74.97 $735.00s
$ email A message will result in:
.97 5.00s
How can i fix this? I feel the problem is with my preg_replace template.
The user template can be any, if there is @@ MESSAGE @@, which will be changed to the user's input.
thanks
string php regex preg-replace cakephp
Harts
source share