I have a search form, in which a user enters a keyword and it displays the results with the keyword in description as highlighted text, for highlighting, i have used another class on that keyword. problem is that, if there is a keyword in some hyperlink or in some <img> tag, it also applies that class there that causes the image load failure and links are not working.
That is how i am fetching my results and highlighting them if there is any keyword.
<?php
if($_GET['key']){
$key = $_REQUEST['key'];
$sql = "select * from tbl_feed WHERE title LIKE '%$key%' OR description like '%$key%'";
$rs = $dbFun->selectMultiRecords($sql);
for($j=0;$j<count($rs);$j++){
$title= mb_convert_encoding($rs[$j]['title'], "iso-8859-1","auto");
$desc = mb_convert_encoding($rs[$j]['description'],"iso-8859-1","auto");
?>
<?php
for($i = 0; $i < sizeof($arrKeywords); $i++){
$title = str_ireplace($arrKeywords[$i], "<font class=\"highlight\">" . $arrKeywords[$i] . "</font>", $title);
$desc = str_ireplace($arrKeywords[$i], "<font class=\"highlight\">" . $arrKeywords[$i] . "</font>", $desc);
}
?>
<a href="<?=$rs[$j]['link']?>" target="_blank"><strong><?=$title?></strong></a><BR />
<?=$rs[$j]['pubdate']?><BR /><BR />
<?=$desc?><BR /><BR /><BR />
<? }
}
is there any way that it skips the html tags from replacing?