Jump to content

Search HTML for a CSS class and grab tag contents?


tmallen

Recommended Posts

How can I pluck out all instances of, for example <div class="foo">...</div> with all enclosing code selected? I'm customizing phpBB to do specific code highlighting, in this case, for CSS. I'll assign each instance to a single array, foreach that (to process the code), and echo the "highlighted" HTML with a number of <spans>.

 

Would this be any easier if I just had phpBB insert unique HTML comments for this BBCode instance, grabbing the contents with Regex? <!-- End CSS --> is easier to pick out than any of a number of </div>, but if PHP has a sense of XHTML open/close rules and nesting, I should be able to take the simpler approach.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.