#native_company# #native_desc#
#native_cta#

Breadcrumbs navigation

By Peter
on March 14, 2001

Version: 1.01

Type: Function

Category: HTML

License: GNU General Public License

Description: This code will produce a useful navigation resource, showing visitors where they are in your site. This form of navigation is recommended by Jakob Nielson, and it really does make navigation less confusing.

Has been tested on PHP4 – not sure if it’ll work on PHP3, as I only wrote the code when my old PHP3 version stopped working when the server was upgraded.

<?php 
/* 
 * Breadcrumbs, version 1.00 
 * This code is copyright (c) Peter Bowyer, and is released  
 * under the GNU general public license. Please leave this  
 * notice intact! 
 * This code was originally written for the F2S unofficial  
 * support site <http://www.users.f2s.com> 
 *  
 * If you modify the code, please let me know.  I am always 
 * after improvements! Contact me at <[email protected]> 
 *  
 */ 

// If your server doesn't support $HTTP_HOST variable, uncomment the lower 
// variable, and enter your site name.  Do not remove the trailing slash! 
$site = "http://".$HTTP_HOST."/"; 
// $site = "http://www.yoursite.com/"; 


//  If you are on a windows machine you may have to alter this line. 
$str = $PHP_SELF; 

ereg("^(.+)/.+..+$", $str, $part); 
$str = $part[1]; 
$str = substr($str, 1); 

// Define the names you want given to each of the directories 
$label =  array("test"=>"Test", 
                "faq"=>"FAQ/Tutorials", 
                "phorum"=>"Forums", 
                "links"=>"Links", 
                "asp2php"=>"ASP2PHP", 
                "whatsnew"=>"What's New", 
                "us"=>"Useful Stuff"); 



if (ereg("/", $str)){ 
$arr = split("/", $str); 
$num = count($arr); 
    for($i=0; $i < $num; ++$i){ 
    echo(" > <a class="drilldown" href="". $site . $arr[$i] ."/">".$label[$arr[$i]]."</a>"); 
    $site = $site . $arr[$i] ."/"; 
    } 
}elseif (ereg("[a-zA-Z_]{1,}$",$str)){ 
$arr = $str; 
echo(" > <a class="drilldown" href="http://".$HTTP_HOST."/".$arr."/">".$label[$arr]."</a>"); 
}else{ 
echo(""); 
} 

?>