一個把字符串按php代碼高亮顯示的函數

發表于:2007-07-14來源:作者:點擊數: 標簽:
///// by iwind.orgcoldwind/iwind/month/ccterran //這個函數是對[code][/code]標簽里的內容進行分析,并輸出 //例如: //? php $string='[code]?$hello=hello;?[/code]sssssssssssss'; //highlight($string); //? //保留了不完全的標簽,如只有[code],沒有[/c
///// by iwind.org  coldwind/iwind/month/clearcase/" target="_blank" >ccterran
//這個函數是對[code][/code]標簽里的內容進行分析,并輸出
//例如:
//  <?php $string='[code]<?$hello="hello";?>[/code]sssssssssssss';
//        highlight($string);
//    ?>
//保留了不完全的標簽,如只有[code],沒有[/code],則輸出中含有[code]
           
function highlight($string){
   $arr=explode("[code]",$string);
   $total=sizeof($arr);
   for($i=0;$i<$total;$i++){
       if(ereg("(.+)\[/code\]",$arr[$i])){
         list($astr,$bstr)=split("\[/code\]",$arr[$i],"2");
         highlight_string($astr);
         echo"$bstr";
       }
else{
     if($i!="0"){
        echo"[code]";
    }
     echo"$arr[$i]";
    }
}
}

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97