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 ( Read more... )

Leave a comment

Comments 2

anonymous September 13 2010, 16:33:45 UTC
Is not just a matter of string replacement, since you're also inserting new values (the end tags). Possibly a regex could do it, but I couldnt.

Technically you could write some code that parses the string and generates tokens (moves it to an intermediary state) then you can print out those tokens in the format you want. However, it's better if you do it at a higher level (ie, what you did: modify the source code that generates the output in the first place) to output the desired result, or at least something more easily parsed.

This is like a vaguely rudimentary version of XSLT

Reply

keless September 13 2010, 16:34:11 UTC
-me

Reply


Leave a comment

Up