ereg() 着色返回显示匹配结束
2012-05-18 16:59:22 来源:WEB开发网核心提示:php;">function replace($str){static $color=0;$color+=50;return "<font style=\"color:rgb(255,".$color.",33)\">".$str.&qu
php;">
function replace($str)
{
static $color=0;
$color+=50;
return "<font style=\"color:rgb(255,".$color.",33)\">".$str."</font>";
}
if( @ereg($match,$str,$array) )
{
if(count($array)>1)
{
$string=$str;
$pos=strpos($string,$array[1]);
$string=substr_replace($string,replace($array[1]),$pos,strlen($array[1]));
$pos=$pos+strlen(replace($array[1]));
echo $string.'<br/>';
for($i=2;$i<count($array);$i++)
{
$pos=strpos($string,$array[$i],$pos);
$string=substr_replace($string,replace($array[$i]),$pos,strlen($array[$i]));
$pos=$pos+strlen(replace($array[$i]));
echo $string.'<br/>';
}
} //end if(count($array)>1)
print_r($array);
}
更多精彩
赞助商链接
