php ereg() 着色返回显示匹配结束
ereg() 着色返回显示匹配结束 [代码片段(30行)]
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); } //该片段来自于http://outofmemory.cn
精彩图集
精彩文章