龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

ereg() 着色返回显示匹配结束

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
span style=color:#e53333;font-weight:bold;错误难免,多多span style=color:#e53333;指出/span!!!/span br / 演试地址: a target=_blank href=http://www.dworry.tk/phptest/post.php rel=nofollowhttp://www.dworry.tk/phptest/post.p
错误难免,多多指出!!!
演试地址: http://www.dworry.tk/phptest/post.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);

	}
精彩图集

赞助商链接