Here i remove all attributes from tags:
$body = preg_replace('/<(\w+) [^>]+>/', '<$1>', $body); //remove attributes from html
How do i amend to exclude style tags?
Here i remove all attributes from tags:
$body = preg_replace('/<(\w+) [^>]+>/', '<$1>', $body); //remove attributes from html
How do i amend to exclude style tags?
You could add a negative lookahead to the regex pattern which excludes style
tags:
$body = preg_replace('/<(?!style\b)(\w+) [^>]+>/', '<$1>', $body);