php - Regular expression stripping $ in one string but not another -


i'm trying use regular expressions add php variables external html page can email html email in phpmailer

the string i'm trying replace is:

<strong> %temp_pass%% </strong></p><p> <a href="http://www.unlimitedtutors.com/forgotpass.php?email=%e%%&p=%mytemppass%%"> 

my regex is:

$hashtemppass = "$2a$10$"; $temp_pass = "'=$.hel3332lo\/'";  $body = file_get_contents('email/forgot_pass_email.html');  $forgot_pass_email = preg_replace('#[0-9a-za-z.%]temp_pass%%#',$temp_pass, $forgot_pass_email); $forgot_pass_email = preg_replace('#[0-9a-za-z.%]mytemppass%%#',"$2a$10$", $forgot_pass_email); 

the problem of $ , number symbols stripped out of mytemppass%%, not temp_pass%% - driving me crazy - doing wrong? fact mytemppass in url? how can include $/. in replacement?

your 2 strings

$hashtemppass = "$2a$10$"; $temp_pass = "'=$.hel3332lo\/'"; 

are interpolating $2 , $. variables. need use single quotes avoid interpolation.

$hashtemppass = '$2a$10$'; $temp_pass = '\'=$.hel3332lo\/\''; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -