tags:

views:

30

answers:

1

I am having an issue removing "%3Cbr+%2F%3E" from my string using the preg_replace function. My assumption is that the '+' char is being interpreted incorrectly. Here my code:

$address = preg_replace('/%3Cbr+%2F%3E/', '', urlencode($address));

Thanks as always!

+6  A: 

The + is a special character in regular expression. It is a quantifier and means that the preceding expression can be repeated one or more times.

Escape it with \+ and it should work:

$address = preg_replace('/%3Cbr\\+%2F%3E/', '', urlencode($address));

But since you’re replacing a static expression, you could also use str_replace:

$address = str_replace('%3Cbr+%2F%3E', '', urlencode($address));
Gumbo
Thnak you Gumbo, you rock!
Mikey1980