Php 面包屑导航链接树问题

Php 面包屑导航链接树问题,php,Php,我正在编写一个小脚本,需要有一个链接树。当我在所需文件中运行下面的代码时,我得到以下结果- 首页»第01位医生»002 Daleks 1-7»index.php 我需要使index.php不会出现在结果中 那么,有人能告诉我我做错了什么,以及如何修复它吗?因为我现在不知所措 谢谢 if($location = substr(dirname($_SERVER['PHP_SELF']), 1)) $dirlist = explode('/', $location); else $dirlist =

我正在编写一个小脚本,需要有一个链接树。当我在所需文件中运行下面的代码时,我得到以下结果-

首页»第01位医生»002 Daleks 1-7»index.php

我需要使index.php不会出现在结果中

那么,有人能告诉我我做错了什么,以及如何修复它吗?因为我现在不知所措

谢谢

if($location = substr(dirname($_SERVER['PHP_SELF']), 1))
$dirlist = explode('/', $location);
else
$dirlist = array();

// Strip out unwanted file names
$dirlist = array_diff($dirlist, array("index.php"));

$count = array_push($dirlist, basename($_SERVER['PHP_SELF']));

// path to main gallery location
$main_gallery = '/gallery';

$address = 'http://'.$_SERVER['HTTP_HOST'].$main_gallery;

echo '<div id="page_nav"><br /><br /><h2>';
echo '<a href="'.$address.'">Home</a>';

for($i = 1; $i < $count; $i++)
    echo '
        &nbsp;&raquo;&nbsp;<a href="'.($address .= '/'.$dirlist[$i]).'">'.$dirlist[$i].'</a>';

echo '</h2>';
if($location=substr(dirname($\u SERVER['PHP\u SELF']),1))
$dirlist=explode(“/”,$location);
其他的
$dirlist=array();
//去掉不需要的文件名
$dirlist=array_diff($dirlist,array(“index.php”);
$count=array_push($dirlist,basename($_SERVER['PHP_SELF']);
//通往主画廊位置的路径
$main_gallery='/gallery';
$address='http://'。$\u服务器['http\u主机].$main\u库;
回音“

”; 回声'; 对于($i=1;$i<$count;$i++) 回声' &",; 回声';
HMM,你可能不想听到这个,但是你可能想考虑一种不同的方法。您将目录名等同于人类可读的面包屑标签(因为链接的
href
和文本都是目录名)。另外,还有更优雅的方法来处理这类事情。解决了问题-替换//去掉不需要的文件名$dirlist=array_diff($dirlist,array(“index.php”)$count=array_push($dirlist,basename($_SERVER['PHP_SELF']);其中$count=count($dirlist);