Msg#: 12819 posted 10:41 am on May 11, 2006 (gmt 0)
I am trying to edit out the words enclosed in round brackets e.g. ( widget ) from my data with the help of str_replace function.
The code I am using is:
$simple = str_replace('(WIDGET)', '', $simple);
As the words in round brackets are many, I ended up having a long series of str_replace statements in my code which have slowed down my script significantly. I wondered that there should be an easy way of doing this in PHP and searched a bit. I came across preg_replace function which is quite close to what I want but could not figure out how to write the pattern so that it can delete all the text that is enclosed in a round bracket.
I must be the oldest newbie to php as I have been playing with it for last two three years but never learnt it systematically. Any help here will be well appreciated :-)