so i have the following script:
<?php
/**
*
* @Create Breadcrumbs Trail.
*
* @copyright Copyright (C) 2008 PHPRO.ORG. All rights reserved.
*
* @version //autogentag//
*
* @license new bsd http://www.opensource.org/licenses/bsd-license.php
*
* @filesource
*
* @package Breadcrumbs
*
* @Author Kevin Waterson
*
*/
class breadcrumbs{
/*
* @string $breadcrumbs
*/
public $breadcrumbs;
/*
* @string $pointer
*/
private $pointer = '»';
/*
* @string $url
*/
private $url;
/*
* @array $parts
*/
private $parts;
/*
* @constructor - duh
*
* @access public
*
*/
public function __construct()
{
$this->setParts();
$this->setURL();
$this->breadcrumbs = '<a class="bc" href="'.$this->url.'">Start</a>';
}
/*
*
* @set the base url
*
* @access private
*
*/
private function setURL()
{
$protocol = $_SERVER["SERVER_PROTOCOL"]=='HTTP/1.1' ? 'http' : 'https';
$this->url = $protocol.'://'.$_SERVER['HTTP_HOST'];
}
/*
* @set the pointer
*
* @access public
*
* @param string $pointer
*
*/
public function setPointer($pointer)
{
$this->pointer = $pointer;
}
/**
*
* @set the path array
*
* @access private
*
* @return array
*
*/
private function setParts()
{
$parts = explode('/', $_SERVER['REQUEST_URI']);
array_pop($parts);
array_shift($parts);
$this->parts = $parts;
}
/**
*
* @create the breadcrumbs
*
* @access public
*
*/
public function crumbs()
{
foreach($this->parts as $part)
{
$this->url .= "/$part";
$this->breadcrumbs .= " $this->pointer ".'<a class="bc" href="'.$this->url.'">'.strtoupper(str_replace('_', ' ', $part)).'</a>';
}
}
} /*** end of class ***/
?>
and the script is called like this:
<?php
/*** a new breadcrumbs object ***/
$bc = new breadcrumbs;
/*** set the pointer if you like ***/
$bc->setPointer('>');
/*** create the trail ***/
$bc->crumbs();
/*** output ***/
echo $bc->breadcrumbs;
?>
so i called this in my pages and i have the following structure:
/games/action/games/name_of_the_game
and the script displays the following:
Start>GAMES>ACTION>GAMES>NAME OF THE GAME
i need somehow to "trim" the "GAMES" links. how can i achieve that?