the way it knows which directory to display and link to is the url GET variable "dir"
ie:
$dir = "$_GET['dir'];
which may be "/dir1/dir2/dir3/dir4"
i amd trying to create a link set at the top of the page so i can go back to anyone of the upper directorys
it will look like this
"home --> dir1 --> dir2 --> dir3"
the link will be some this like mypage.php?dir=/dir1
so the above example would be
mypage.php --> mypage.php?dir=/dir1 --> mypage.php?dir=/dir1/dir2 --> mypage.php?dir=/dir1/dir2/dir3
my code is displaying 2 of every link and also i cant get it to inclue all the previous directorys like this one "mypage.php?dir=/dir1/dir2"
Code: Select all
<?php
$links = explode( "/", $_GET['dir'], 2 );
echo $_GET['dir'] . "<br/><br/><br/>"; //Testing
echo $links . "<br/><br/><br/>"; //Testing
if ( ($_GET['dir']) != "" and is_array($links) )
{
for ( $i = 1; $i <= sizeof($links); $i++ )
{
if ( $links[$i] != "" )
{
foreach ( $links as $link )
{
echo " -> <a href=\"{$_SERVER[PHP_SELF]}?inc=z&dir={$link}\">$link</a> ->";
}
}
}
}
?>