当前位置: 网学 > 编程文档 > PHP > 正文

php下正则来匹配dede模板标签的代码

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/21
",'''',$vsstr);
/*过滤后缀 {/t:array} 取得中间文本.
可能出现,空格或者换行所以使用正则,也可直接使用strtr 替换 。
{/t:array }
{/t:array
}
strtr(strtolower($vsstr),array($skstr.''/''.$skdstr.$rarr[''tagname''].$sdstr=>''''));
*/
unset($va[0]);
$attr=array();
foreach($va as $val){//循环记录属性
$val=strtr($val,$glarr2); //typeid=''1'' 去掉 " '' / , typeid=1
$vc=explode(''='',$val);
if(!empty($vc[0])){
$vc[0]=strtolower($vc[0]); //小写属性名
if($vc[0]=="function"){
$rarr[''function'']=$vc; //返回要执行的 html2text(@me)
}else if($vc[0]=="name"){
$rarr[''tagfield'']=$vc; //{t:field name=''title'' /}
}else{
$attr[trim($vc[0])]=$vc; //属性 $attr[''typeid'']=1;
}
}
}
$rarr[''attr'']=$attr;
$CTags[$k]=$rarr;
}
echo "<pre>";
print_r($CTags);
echo "</pre>";
?>

输出内容:
复制代码 代码如下:
Array
(
[0] => Array
(
[str] => {t:arc row=''10''}
{t:field.title/}
{t:list row=''5''}
{t:field.title/}
{t:list row=''5''}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
{/t:arc}
[tagname] => arc
[tagfield] =>
[text] =>
{t:field.title/}
{t:list row=''5''}
{t:field.title/}
{t:list row=''5''}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
[attr] => Array
(
[row] => 10
)
)
=> Array
(
[str] => {T:channelartlist
row=''6''
}
{t:field name=''typename''/}{t:field.typename/}
{t:arclist titlelen=''42'' row=''10''}
[field:title/]
([field:sendtime function="MyDate(''m-d'',@me)"/])
{/t:arclist}
{/t:channelartlist
}
[tagname] => channelartlist
[tagfield] =>
[text] =>
{t:field name=''typename''/}{t:field.typename/}
{t:arclist titlelen=''42'' row=''10''}
[field:title/]
([field:sendtime function="MyDate(''m-d'',@me)"/])
{/t:arclist}
[attr] => Array
(
[row] => 6
)
)
=> Array
(
[str] => {t:global.cfg_title
/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
=> Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
=> Array
(
[str] => {t:global.cfg_webname /}
[tagname] => global
[tagfield] => cfg_webname
[text] =>
[attr] => Array
(
)
)
=> Array
(
[str] => {t:global.cfg_title/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
=> Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
=> Array
(
[str] => {t:field.title function="Html2Text(@me)"/}
[tagname] => field
[tagfield] => title
[text] =>
[function] => Html2Text(@me)
[attr] => Array
(
)
)
=> Array
(
[str] => {t:include
filename="header.htm"/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
=> Array
(
[str] => {t:include filename="header.htm"
/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
[10] => Array
(
[str] => {t:field.

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号