欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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);