search function puzzle..wots going on?
Posted: Tue Apr 06, 2004 12:18 pm
I am have downloaded a search function and it seems to work wonders but How is the bottom code working within the search file?
Can someone help me understand exactly what the function below is doing.
Note: this is just a small part of the whole search.php file
Can someone help me understand exactly what the function below is doing.
Note: this is just a small part of the whole search.php file
Code: Select all
function hl($str) {
GLOBAL $lq;
$str=" ".$str;
$ph=explode(" ",$lq);
$lstr=mysql_result(mysql_query("SELECT lower('$str')"),0,0);
for ($i=0;$i<count($ph);$i++) {
$lstr=eregi_replace($phї$i],"<b><font color=red>".$phї$i]."</font></b>",$lstr);
}
$p1=1;$p2=1;
while ($p1!=0 && $p2!=0) {
if (($p1=strpos($lstr,"<b><font color=red>"))!=0) {
$lstrї$p1]="|";
$str=substr($str,0,$p1)."<b><font color=red>".substr($str,$p1);
if (($p2=strpos($lstr,"</font></b>"))!=0) {
$lstrї$p2]="|";
$str=substr($str,0,$p2)."</font></b>".substr($str,$p2);
}
}
}
$str=substr($str,1);
return($str);
}