phpcms 导航 当前位置
程序员文章站
2022-03-30 15:23:50
...
代码
$CATEGORY = array( '1'=>array('catid'=>'1','catname'=>'新闻中心','arrparentid'=>'0'), '2'=>array('catid'=>'2','catname'=>'世界新闻','arrparentid'=>'0,1'), '3'=>array('catid'=>'3','catname'=>'国内新闻','arrparentid'=>'0,1'), ); function catpos($catid, $urlrule = '') { global $CATEGORY; if(!isset($CATEGORY[$catid])) return ''; $pos = ''; $arrparentid = array_filter(explode(',', $CATEGORY[$catid]['arrparentid'].','.$catid)); foreach($arrparentid as $catid) { if($urlrule) eval("\$url = \"$urlrule\";"); else $url = $CATEGORY[$catid]['url']; $pos .= '<a href="'.$url.'">'.$CATEGORY[$catid]['catname'].'</a>'; } return $pos; } echo catpos(3);
上一篇: 实例详解用vue封装插件并发布到npm