How match all h1-h6 tags in PHP

For match all H tags in html code you need do this:

preg_match_all('/<h([1-6]).*[^>]*>(.*)<\/h([1-6])>/',$content,$all_h_tags);

Where $content is a string variable with html tags and $all_h_tags is a variable where puts all matches.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>