站长统计的代码优化 不指定

Else , 2010/07/30 02:25 , 代码片段,演示也有 , Comments(0) , Reads(1241) , Via Original
这样优化,可以让网页更标准,如果是动态保存的值!
$htmstr = <<<eot
<script src="http://s15.cnzz.com/stat.php?id=129471&web_id=129471&show=pic" type="text/javascript"></script>
eot;


$pattern =  "/(?<=src=\")([^\>]+?)(?=\")/i";

preg_match($pattern, $htmstr, $matchesarray);

$search = $matchesarray[0];

$replace = str_replace('&', '&amp;', $search);


echo str_replace($search, $replace, $htmstr)
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]