php信息导航栏的代码编写
<? if(!isset($_GET["id"])){ $id="home"; } else $id=$_GET["id"]; $page_arr=Array( "home"=>Array( "title"=>"home","url"=>"daohang.php?id=home","parent"=>""), "news"=>Array( "title"=>"news","url"=>"daohang.php?id=news","parent"=>"home"), "lzyy"=>Array( "title"=>"lzyy","url"=>"daohang.php?id=lzyy","parent"=>"news") ); //echo $page_arr["home"]["title"]; function daohang($id,$pages){ if(!array_key_exists($id,$pages)) die("参数错误"); $cur_page=array(); $page_id=$id; while(strlen($page_id)>0){ $cur_page[]=$pages[$page_id]; $page_id=$pages[$page_id]["parent"]; } for($i=count($cur_page)-1;$i>=0;$i--){ if($i>0){ echo "<a href=".$cur_page[$i]["url"].">"; } echo $cur_page[$i]["title"]; //print_r($cur_page); if($i>0){ echo "</a>-->"; } } } ?> <html> <head> <title><? echo $id; ?></title> </head> <body> <? daohang($id,$page_arr); ?> </body> </html>