Home > php教程 > php手册 > 再来一个一个把字符串按php代码高亮显示的函数

再来一个一个把字符串按php代码高亮显示的函数

WBOY
Release: 2016-06-21 09:11:39
Original
1125 people have browsed it

高亮显示|函数|字符串

///// by iwind.org  coldwind/iwind/month/ccterran
//这个函数是对标签里的内容进行分析,并输出
//例如:
//  

以下内容为程序代码

$hello="hello";?>

sssssssssssss';
//        highlight($string);
//    ?>
//保留了不完全的标签,如只有

以下内容为程序代码

,没有

,则输出中含有[code]
           
function highlight($string){
   $arr=explode("[code]",$string);
   $total=sizeof($arr);
   for($i=0;$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]";
    }
}
}



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template