Skip to content

Instantly share code, notes, and snippets.

@huzaifa-a
Created September 10, 2020 22:06
Show Gist options
  • Save huzaifa-a/ca6e0df078fbdf180a8950b104ea435b to your computer and use it in GitHub Desktop.
Save huzaifa-a/ca6e0df078fbdf180a8950b104ea435b to your computer and use it in GitHub Desktop.
remove span tag inside a heading
$match = preg_replace('/(<h(1|2|3|4|5|6)[^>]*>)<span[^>]*>(.*)<\/span>(?=(<\/h(1|2|3|4|5|6)>))/','$1$3', '<h2 id="toc-item-1"><span style="font-weight: 400;">Online Doctor Reviews 2020</hs></span></h2>');
return var_dump($match);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment