Hi I'm looking for a way to strip everything that goes before opening and after the closing html tag. Whats the best way to do this? I still want to keep the <html> tags in the string though. Just the garble before and after.
Any help woul be great!
<?php $str = ' blah blah <html> Valid html! </html> more bs '; $pattern = '/^.*(<html>.*<\/html>).*$/s'; if (!preg_match($pattern, $str, $matches)) { die('no matches!'); } echo $matches[1]; ?>