0

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?

1

1 Answer 1

0

You could add a negative lookahead to the regex pattern which excludes style tags:

$body = preg_replace('/<(?!style\b)(\w+) [^>]+>/', '<$1>', $body);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.