Beadcrum in php

##  FOR DYNAMIC BREADCRUM::


filename = breadcrum.php;

<?php
class breadcrumb_class
{
    var $breadcrumb = array();

    function insertBreadcrumb($title,$path="#")

    {

        $this->breadcrumb[$title] = $path;

    }     

    function retrieveBreadcrumb()
    {
     end($this->breadcrumb); 
     $key_last = key($this->breadcrumb);

foreach ($this->breadcrumb as $key => $value) {

         if ($key != $key_last) {

 $output[] = '<li><a href="'.$value.'"><font color="black">'.$key.'</font></a></li>';

}
else {
 $output[] = '<li><font color ="red">'.$key.'</font></li>';

        }
     }         
     return implode('  ', $output);
    }
}


## USE IN PAGE

include("breadcrum.php");

$bread = new breadcrumb_class();

$bread->insertBreadcrumb('Home','index.php');

$bread->insertBreadcrumb('About Us','gasdfgdsha');    

$bread->insertBreadcrumb('About Us2');    

echo $bread->retrieveBreadcrumb();
Please follow and like us:
0