preg_replace help???

Hello everyone,

I am attempting to use preg_replace but am having some difficulty.

Here is my code

$patterns[0] = “/javascript:assignRatePlan(’/”;
$patterns[1] = “/’);/”;
$patterns[2] = “/cgi-bin/”;
$patterns[3] = “NASApp/”;

$replacements[0] = “http://www.phones-nextel.com/nextel.php?data=index&ext=php&t=shop&action=add_plan&plan=”;
$replacements[1] = “&zipcode=$zipcode”;
$replacements[2] = “redirect.php?location=”;
$replacements[3] = “test”;

ksort($patterns);
ksort($replacements);

$new_code = substr($code, 115, 100000); // Returns “Removes some javacode we dont need”

$apple = preg_replace($patterns, $replacements, $new_code);
echo("$apple");

My problem is only 0-2 are being replaced. My number 3 variable is not changing what I need changed. Could someone offer some sugguestions?

Thank You

Maybe its because you are missing the / in front of your pattern.

Its the little things that will get you.

I wish it was that simple. In statements 0 1 & 2 I am replacing the /… In statement 3 I don’t need to replace the /. I tried it anyways for the heck of it and that didn’t work. Anything Else?

Nevermind I was bale to correct the error. It did matter with the /… I needed it in the beginning and the end. Thanks

Aye, the pattern needs a delimiter.

Sponsor our Newsletter | Privacy Policy | Terms of Service