Jump to content

Trying to str_replace an entire mail message.


scrubbicus

Recommended Posts

The body would be something like:

 

$body =

"Thank you for registering with ^^url_name^^, if you could just click the link below to activate your account you can navigate throughout the entire network with just one login!

 

^^activation_link^^

 

Once clicked, you'll be brought to your control panel where you can start editing your online information and more menus will be opened up for you. We hope you find what you were browsing for.

 

Thanks,

^^site_name^^

^^url_link^^

";

 

$replace = array(

"^^site_name^^" => "ScrubbDesigns",

"^^url_name^^" => "<a href=\"http://www.url.com\">Name</a>",

"^^url_link^^" => "<a href=\"http://www.url.com\">www.url.com</a>",

"^^activation_link^^"         => $activation_link,

"^^to_name^^" => $to['name'],

"^^to_email^^" => $to['email'],

"^^from_email^^" => $from['email'],

"^^subject^^" => $from['subject'],

"^^message^^" => $from['message'],

"^^find_us^^" => $from['find'],

"^^from_name^^" => $from['name'],

);

 

foreach($replace as $k => $v) echo "str_replace($k,$v,$body) <P />";

Well a few things...

 

str_replace allows for an array input of search and an array of replacement values. You might want to look into that instead.

 

And when echo'ing the return value of a function, the function must not be inside of quotes. You have:

echo "str_replace($k,$v,$body) <P />";

It would need to be:

echo str_replace($k,$v,$body)." <P />";
// or
echo str_replace($k,$v,$body)," <P />";

Oh I took the test version. I wanted to echo what the PHP code actually was to see if all the values that needed to be passed to it was being passed.

 

It's actually no echo, it's just foreach($replace as $k => $v) str_replace($k,$v,$body);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.