Click to See Complete Forum and Search --> : highlighting text


IxxI
01-23-2003, 08:24 AM
Does anybody know how to highlight text that relates to a search keyword that has been entered? As in if I searched for "does" in this question then the first word would be highlighted.
Thanks
IxxI

php_new_user
06-01-2007, 06:32 AM
Can we do that using PHP ?
I have following script , which searches file for a keyword(Search String) , If it is there it
will store the filename. Finally list of files which are stored in an array displayed using an array.
BUT the thing is : while displaying search results
we need to display the file name + some content of file in which key words should be highlighted.
Can we do like that ???


$data=fread(fopen("somefile","r"),filesize("somefile"));
if(eregi("$keyword",$data))
{
$array[]="somefile";
}

kiwibrit
06-01-2007, 06:41 AM
......... in which key words should be highlighted.
Can we do like that ???


Yes (http://www.google.com/search?q=php+highlight+search+result&sourceid=opera&num=0&ie=utf-8&oe=utf-8).