...

View Full Version : how can php read + sign



meshi
02-19-2008, 11:20 AM
i have this script
function highlight($c,$q){
$q=explode('|',$q);
for($i=0;$i<sizeOf($q);$i++){
if (strlen($q[$i])==1){
$c=eregi_replace('[[:<:]]' . $q[$i] . '[[:>:]]', "<span class='z'>" .$q[$i]. "</span>", $c);}
else {
$c=preg_replace("/($q[$i])(?![^<]*>)/i","<span class='z'>\${1}</span>",$c);
}

}
return $c;
}
this code can highlight the search keyword.the problem is when i search c++ or C## only c is highlighted.i want to highlight the full word c++.please help me:(

kbluhm
02-20-2008, 09:22 PM
Give this a shot:


function highlight( $c, $q )
{
$q = explode( '|', $q );
for ( $i = 0, $len = count( $q ); $i < $len; $i++ )
{
$c = preg_replace
(
'/(' . preg_quote( $q[$i], '/' ) . ')/Ui',
'<span class="z">\1</span>',
$c
);
}
return $c;
}

meshi
02-21-2008, 01:57 PM
thats really a good on one kbluhm..thanx in a million



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum