I've done things like this using variations of substring and replace. I'd probably use regex today but you wanted an alternative so:
For the <i>
tags, I'd do something like:
$text = replace($text, "<i>", "");
$text = replace($text, "</i>", "");
(My php is really rusty, so replace
may not be the right function name -- but the idea is what I'm sharing.)
The <a>
tag is a bit more tricky. But, it can be done. You need to find the point that <a
starts and that the >
ends with. Then you extract the entire length and replace the closing </a>
That might go something like:
$start = strrpos( $text, "<a" );
$end = strrpos( $text, "</a>", $start );
$text = substr( $text, $start, $end );
$text = replace($text, "</a>", "");
(I don't know if this will work, again the idea is what I want to communicate. I hope the code fragments help but they probably don't work "out of the box". There are also a lot of possible bugs in the code snippets depending on your exact implementation and environment)
Reference: