scrubbicus Posted August 19, 2009 Share Posted August 19, 2009 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 />"; Quote Link to comment https://forums.phpfreaks.com/topic/170934-trying-to-str_replace-an-entire-mail-message/ Share on other sites More sharing options...
Philip Posted August 19, 2009 Share Posted August 19, 2009 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 />"; Quote Link to comment https://forums.phpfreaks.com/topic/170934-trying-to-str_replace-an-entire-mail-message/#findComment-901525 Share on other sites More sharing options...
ignace Posted August 19, 2009 Share Posted August 19, 2009 str_replace($k,$v,$body) . '<P />' should be: '<p>' . str_replace($k,$v,$body) . '</p>' Quote Link to comment https://forums.phpfreaks.com/topic/170934-trying-to-str_replace-an-entire-mail-message/#findComment-901675 Share on other sites More sharing options...
thebadbad Posted August 19, 2009 Share Posted August 19, 2009 As KingPhilip said, you could simply do $body = str_replace(array_keys($replace), $replace, $body); instead of that foreach loop. Quote Link to comment https://forums.phpfreaks.com/topic/170934-trying-to-str_replace-an-entire-mail-message/#findComment-901710 Share on other sites More sharing options...
scrubbicus Posted August 21, 2009 Author Share Posted August 21, 2009 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); Quote Link to comment https://forums.phpfreaks.com/topic/170934-trying-to-str_replace-an-entire-mail-message/#findComment-903678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.