If you wish to get a part of path you can use function like this:
<?php
function getPartPath($path = '', $depth = 0) {
$pathArray = array();
$pathArray = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
if($depth < 0)
$depth = count($pathArray)+$depth;
if(!isset($pathArray[$depth]))
return false;
return $pathArray[$depth];
}
?>
usage:
<?php
$a = "/var/www/foo/trunk/bar/tools/php/simplelocal";
var_dump(getPartPath($a, -2)); var_dump(getPartPath($a, 0)); var_dump(getPartPath($a, -1)); ?>
etc...
Regards.