php - how to replace duplicate text using highlight_phrase in codeigniter -
i new codeigniter trying learn it. trying replace text anchor tag.
but problem if text inside <a> tag has property of href,
it replaced. want replace text inside anchor tag , not include href. here code.
<?php $string = "text1 text1-a text1-b"; $array = explode(' ', $string); $tofind = "text1"; foreach($array $value){ $string = highlight_phrase($string,$tofind,"<a href=\"{$value}\">","</a>"); } echo $string; ?> //the output should // <a href="text1">text1</a> text1-a text1-b // **wrong** result replace "text1" inside href. // <a href="text1">text1</a> // <a href="<a href="text1"></a>-a">text1-a</a> // <a href="<a href="text1"></a>-a">text2-a</a>
does know how fix this? thanks
Comments
Post a Comment