how to exclude from strip tag function by specific class

434 Views Asked by At

i want to strip tag a string and exclude an a tag by specific class Name.

have this input :

<p><a class="className">Text</a></p>

want this output:

<a class="className">Text</a>
1

There are 1 best solutions below

0
On
strip_tags(STRING, ALLOW TAG);

<?php
$text = '<p><a class="className">Text</a></p>';
echo strip_tags($text, "<a>");
?>