<?
/**********************************************************************************************
* DEMO for highlighter.php CLASS by Bojidar Naydenov a.k.a Bojo (bojo2000@mail.bg) & Antony Raijekov a.k.a Zeos (dev@strategma.bg)
**********************************************************************************************
* This class highlights text matches a search string (keyword) in html based documents, without destroying html-tags.
* This was necessary to scan database-entry written in html by keywords, and display them in another style.
**********************************************************************************************/
include("highlighter.class.php"); //include class
/********************************************************************************************
* DEMO code
********************************************************************************************/
// assume $text is content of article ot some other text
$text = "<div>text <table>
<tr>
<td valign=top> <IMG src=\"http://aces.ee.olemiss.edu/images/test.gif\" title=\"test\">
</tr>
</table> <B>test</B> text <a href=\"test.php\">tester</a> <A HREF=\"index.php?seek=test\" style=\"color:green\">test is tester but is not good</A> text.Test.</div>";
//create hightlight instance class, with keyword(test) and replacement (<u>{keyword}</u>)
//NOTE: the {keyword} in second argument (replacement) is alias for matching keyword.
$h = new highlight ('test','<u style="background-color:#B5B5B5">{keyword}</u>');
//print original text
print $text;
print "<hr>";
//print it proceed with hightlight
print $h->process($text);
print "<hr>";
?>
|