I have captured the <h1>
tag and its inner contents from a webpage and I need to remove the <h1>
and </h1>
parts of the string. The problem is that I won't know if the tag is written as <h1>
or <h1 id="something">
, etc. I know I can write
$tag = str_replace("<h1>", '', $tag);
$tag = str_replace("</h1>", '', $tag);
But how can I handle the more general case, where it may be <h1 id="something">
, or something else?