Jump to content

finding the beginning of certain tags


yahn

Recommended Posts

What do you mean you want to find the beginning?  Do you just want to verify the tags, or do you want some content, too?

 

<?php

// To simply verify tags, you can use:
preg_match_all('/<(?:html|head|body)[^>]*>/i',$html,$matches);

// To capture the opening tags, use:
preg_match_all('/(<(?:html|head|body)[^>]*>)/i',$html,$matches);

// To capture the opening tag, closing tag, and everything in between:
preg_match_all('/<(html|head|body)[^>]*>(.*?)<\/\1>/i',$html,$matches);

?>

 

You can use the PREG_OFFSET_CAPTURE flag to find where the offset is.

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.