I know strip_tags() removes html tags from a string of text. I don't know if striptags can help for my question, but how would I allow 2 <a> tags and remove the 3rd, 4th, 5th, ... <a> tags?
example:
$str= "<b>This text</b> has <a href="#">1 link</a>, a <a href="#">2nd link</a> and a <a href="#">3rd link</a>.";
$str = strip_tags($str, "<a>");
echo $str;
This text has 1 link, a 2nd link and a 3rd link.
How can I make it display this instead?
