I don't really need to know but...

Sep 09, 2010 18:56

Not knowing is really gonna bug the crap out of me. So if any of you PHP gurus have a minute...

I've got a string, $output, that has the following in it:

Main Category
Child
Main Category
Child

I need to take that string and poke it repeatedly until it becomes

Child

Child

["Main Category" and "Child" are placeholders for real names and the integer values will vary]

It seems like there's gotta be some way to accomplish this with one or more string functions (preg_replace, etc), but I'll be damned if I can think of something that'd work... I mean changing the option tag to the optgroup tag is cake, but I can't figure out how I'd get rid of the option tags for JUST those while retaining the main category names... I can't rely on the idea that an optgroup will be followed by options either, because the client will inevitably stick in blank ones as placeholders. (In fact, I already have a blank one lol)

For the moment I've hacked the core code instead (the code that generates that output in the first place), which works, but it irritates me that I had to resort to that.
Previous post Next post
Up