Hi,
I copied this function which highlights search results into my page:
function highlight( $needle, $haystack ) {
$parts = explode( strtolower($needle), strtolower($haystack) );
$pos = 0;
foreach( $parts as $key=>$part ){
$parts[ $key ] = substr($haystack, $pos, strlen($part));
$pos += strlen($part);
$parts[ $key ] .= '<FONT COLOR="#009000"><B>'.substr($haystack, $pos, strlen($needle)).'</B></FONT>';
$pos += strlen($needle);
}
return( join( '', $parts ) );
}
// highlight search results
if ($type == "area") {
highlight($value, $area);
$area=$parts; }
When I run this code I get this error :
"Fatal error: Cannot redeclare highlight() (previously declared in /search_results.php3:49) in /search_results.php3 on line 49"
(line 49 is the "function" line)
The word "highlight" is only used in the two places as shown. I'm coming to the conclusion that I'm really thick 'cos I can't see what's wrong. Can you ?
Thanks