Skip to content
WJunction - Webmaster Forum

Php replacing characters !

Status
Not open for further replies.

softleaks

Experienced Member
666
2011
153
hi my database has text with characters like this : "%28" , "%29"

i guess they are coming instead of the curly braces : "(" , ")"


i just want to filter these things out.

"str_replace" function is not working for this characters.

can somebody give me an alternate method in doing this ???

thanks.
 

8 comments

major problem here is, i cant understand what u want. Otherwise str_replace works fine if u need to replace some text
 
i tried with str_replace. It is not working.

this is my code :

$a="%282009%29";
str_replace("%28","",$a);

have u tried
str_replace("(","",$a) ?

maybe, it is saved in html encoded format in DB & retrieved as proper character
 
i guess u forgot to assign the value of replace function back to variable

$a="%282009%29";
$a=str_replace("%28","",$a);

?
 
Yeah its not working because str_replace returns, it doesn't change by reference.

you need to assign it to a variable.

Also see urldecode().
 
^agree with JmZ. need urldecode() but if you want to use str_replace for them (if you're fussy) use this:

$str = "%29 lolcat %28";
echo str_replace(array("%29","%28"), array("\)","\("), $str);

should do the trick.
 
Status
Not open for further replies.

About the author

S
Experienced Member · Joined
666
Messages
153
Reactions
246
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom