Web Hosting Talk







View Full Version : str_replace question


matt2kjones
11-10-2002, 09:47 AM
ok im makeing a reviews script for someone

and i want them to be able to use bbcode in their posts instead of html.

I am using str_replace() to do this, but i have a problem.

i can do this fine :

$reviews_post = str_replace("[b]", "<b>", $reviews_post);

but how do you do it if you want to change not only to <b> but [b] and to <b> and </b> in one go?

Thanx :)

matt2kjones
11-10-2002, 09:51 AM
ok that post has come out all wrong because it is converting the bbcode to bold

is there not a way to turn it off in a post?

Thanatos
11-10-2002, 07:45 PM
I you want to show bbcode in a post you can place bbcode in a bbcode to break it up; like this: wassup! (quote me and see what i mean)

sasha
11-10-2002, 10:23 PM
From Manual: In PHP 4.0.5 and later, every parameter to str_replace() can be an array.

That might mean that this will work:


str_replace (array('', '') , array(<b>', '</b>') ,$str) ;