I can't use this because there is some other stuff that is also in % signs... The whole line is as thus: $string = "a href=\"{$_SERVER['PHP_SELF']}?thing=do&id=%number%\">%some% - %stuff% %if%%artist%?(%artist% Minutes):\"WAH!\"%if%</a>";
So doing an explode on all the % signs would not work unfortunately. Thanks, Mike -----Original Message----- From: Richard Lynch [mailto:[EMAIL PROTECTED]] Sent: Saturday, August 24, 2002 7:36 PM To: Mike Cc: [EMAIL PROTECTED] Subject: [PHP] Re: An if statment that someone else designed and I can't parse ;( >This may not be the best place to post this question, but I don't know >where else to ask it, so here it goes. >I have a program that someone was helping me to build and one of the >functions returns a string similar to this: "%if%(%value%)?(%value%>Minutes):\"WAH!\"%if%" Personally, I think Regex is (A) overkill and (B) over-complicated. But I'm not very smart. :-) I would do: <?php $string = "%if%(%value%)?(%value%>Minutes):\"WAH!\"%if%"; $parts = explode('%', $string); # That gets you pretty close: # array(0=>if,1=>(,2=>value,3=>)?(,4=>value,5=>>Minutes):"WAH!",6=>if) /* I suspect that there are more %'s in your input, and you might be "finished" at this point... If not, use explode some more: */ $minuteswah = $parts[5]; $minuteswah = explode('):', $minuteswah); ?> Basically, a couple explode calls over the headache of trying to understand some convoluted Regex is always a "win" in my book. :-) http://php.net/explode -- Like Music? http://l-i-e.com/artists.htm -- 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