Ok, It works and everything, but I just was wondering: $data = ereg_replace('(.*(\(|\[)|(\)|\]).*)', '', ${$data}); --------------------------------------------------^ ^ what does this do exactly, I see that you are replacing all the characters [] and () but what is the ${$data} for? Also for future reference is there a way that you could return the string with all the parentheses stripped out? Thank You again, Mike [EMAIL PROTECTED]
And what would be -----Original Message----- From: Tech Support [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 25, 2002 11:39 AM To: Mike; PHP List Subject: Re: [PHP] String Manipulation I tested this out with success. $string = ereg_replace('(.*(\(|\[)|(\)|\]).*)', '', $string); ################### // Here is actual working code $string1 = "(Something) - is wrong with me"; $string2 = "something - (is wrong with me)"; $string3 = "something - (is wrong with me"; $string4 = "[something] - is wrong with me"; $string5 = "something - [is wrong with me]"; $string6 = "something - [is wrong with me"; for ($i = 1; $i < 7; $i++) { $data = "string" . $i; $data = ereg_replace('(.*(\(|\[)|(\)|\]).*)', '', ${$data}); // the magic line. feed it the string(s). print "<b>$i)</b> $data<br>"; } ################### Jim Grill Support Web-1 Hosting http://www.web-1hosting.net ----- Original Message ----- From: "Mike" <[EMAIL PROTECTED]> To: "PHP List" <[EMAIL PROTECTED]> Sent: Thursday, July 25, 2002 10:13 AM Subject: [PHP] String Manipulation > Hello all, > I know that this has probably been discussed before and that you will > tell me to go through all the back messages on the list but I really > don't have time to do that because I am on a really tight schedule, but > I was wondering if anyone could give me some pointers on how to pull > some information out of a string. I have something like this: > (Something) - is wrong with me > or > something - (is wrong with me) > or > something - (is wrong with me > > what I need to know how to do is take the stuff that is inside the > Brackets (or partial brackets) and put them into another string > the way I am currently doing it is like this: > Variable names have been changed per my boss(My Boss wanted me to change > them for some reason) > <? > $parenpos = strpos($tartist,")"); > $bracketpos = strpos($tartist,"]"); > if($parenpos){ > $artist = trim(substr($tartist,0,$parenpos)); > $title = trim(substr($tartist,$parenpos+3)); > $secondparenpos = strpos($title,"("); > $secondbracketpos = strpos($tartist,"["); > $title = trim(substr($title,0,$secondparenpos)); > }elseif($bracketpos){ > $artist = chop(substr($tartist,1,$bracketpos-1)); > $title = trim(substr($tartist,$bracketpos+3)); > } > ?> > > I know that there has to be a shorter version of this, can anyone help > me out with it? > > Thank You, > Mike > [EMAIL PROTECTED] > [EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php