txt.html
<html>
<body>
<include file="Tpl/top.html">
<div></div>
<include file="Tpl/foot.html">
</body>
</html>$txt=file_get_contents("txt.html");//include替换
$return = preg_match_all("/<\s*include\s+file=\"(.*)\"\s*>/", $txt, $inc);
if ($return) {
$inc1 = $inc[0]; //<include file="top.html">系列数组
$inc2 = $inc[1]; //top.html 系列数组
foreach ($inc2 as $v) {
if (file_exists($v)) {
$sub = file_get_contents($v);
foreach ($inc1 as $v1) {
//区分大小写匹配
if (ereg($v, $v1)) {
$txt = str_replace($v1, $sub, $txt);
}
}
} else {
exit("include标签解析出错!");
}
}
}
echo $txt;
//--include替换
谁能写出更好的include标签解析代码
<html>
<body>
<include file="Tpl/top.html">
<div></div>
<include file="Tpl/foot.html">
</body>
</html>$txt=file_get_contents("txt.html");//include替换
$return = preg_match_all("/<\s*include\s+file=\"(.*)\"\s*>/", $txt, $inc);
if ($return) {
$inc1 = $inc[0]; //<include file="top.html">系列数组
$inc2 = $inc[1]; //top.html 系列数组
foreach ($inc2 as $v) {
if (file_exists($v)) {
$sub = file_get_contents($v);
foreach ($inc1 as $v1) {
//区分大小写匹配
if (ereg($v, $v1)) {
$txt = str_replace($v1, $sub, $txt);
}
}
} else {
exit("include标签解析出错!");
}
}
}
echo $txt;
//--include替换
谁能写出更好的include标签解析代码
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货