I'm happy to try your solution on my site right now Rob, I'll play with it for a while and see what I come up with.
But now I'm looking for that post which mentioned some full HTML parsing module in PHP and I can't find it.
'Shindig'
Do you have problems, concerns or recommendations about the technical side of the Phoenix? Air them here. Compliments also welcome.
I'm happy to try your solution on my site right now Rob, I'll play with it for a while and see what I come up with.
But now I'm looking for that post which mentioned some full HTML parsing module in PHP and I can't find it.
gaping openmouthed at Things I Don't Understand
cheering
OK, using Rob's model of reversing through the array of open ones and removing all which match a closing one, check out [link] -- and I'm going to lunch! Back in a while...
You are all so goddam cool.
When are you going to learn PHP, Rebecca, and be like all the cool kids? t /peergrouppressure
OK, I've hit a snag.
I used Rob's model, which is:
each time you find an open tag, push it into the array. Each time you find a closing tag, search your array from the end going backwards until you find a matching open. Delete the matching open from the array.
At the end, walk the array backwards and emit one closing tag for each opening tag still in the array.
which works, but it works too well.
I've got two "for" loops:
for(all of our closing tags){ for(all of our opening tags, in reverse order){ if (closing tag matches opening tag){ delete the opening tag; } } }
so what happens when we're checking a close-font tag against a list which has two or more opening tags in it? It kills them both because we're iterating through the list.
What I need is to do this:
for(all of our closing tags){ for(all of our opening tags, in reverse order){ if (closing tag matches opening tag){ delete the opening tag; next, but not in this loop, in the outer loop; } } }
or, as usual, I'm missing something obvious and you're all laughing at me.
Can I do a "next in outer loop" in PHP? Or have I got a fundamentally silly structure?
break
should pop you out one loop.
Aha, ita, you rock.
Do the dance of break.
Or not, because ... breakdancing.
[Edit: not only may I do a break, break in PHP has an optional number, so I can break out of the loop I'm in or any number of enclosing loops.]
I had imagined searching and removing the tags from the open list immediately after finding a close tag, as opposed to collecting all the opens and closes and doing it after. I don't think it makes a difference, except it might be slightly more efficient doing it immediately, since in most cases the list of open tags will never get very long.
Break with a number scares the hell out of me.
I had imagined searching and removing the tags from the open list immediately after finding a close tag, as opposed to collecting all the opens and closes and doing it after.
That's in the list of "Things I Know How To Do In Perl, But Not In PHP" I'm afraid.
I'm using a regex function to grab all the openers and put them in an array, and the same function to grab all the closers, but I don't see a way to do "while(still finding tags){code}" in PHP.