Capturing HTML headings : preg_match_all « String « PHP
- PHP
- String
- preg_match_all
Capturing HTML headings
<?php
$html = file_get_contents('example.html');
preg_match_all('@<h([1-6])>(.+?)</h\1>@is', $html, $matches);
foreach ($matches[2] as $text) {
print "Heading: $text \n";
}
?>
Related examples in the same category