...

View Full Version : catch subfolder



mb89
06-25-2007, 06:50 AM
Hi,
I have been using
$script = strrchr($_SERVER['PHP_SELF'],"/");
$script = str_replace("/", "", $script); to catch the script of the page you're on then execute if/else statements on the outcome. I've hit a slight snag because now I need to get the subfolder that its in and only the subfolder, how do I say grab whats in between the second last "/" and the last "/" ???? confused!

firepages
06-25-2007, 07:23 AM
<?php
$bits=explode('/',$_SERVER['PHP_SELF']);
echo $bits[(count($bits)-1)];
?>

or is it -2 ?

Serex
06-25-2007, 07:31 AM
nice hehe, I've always found the long way around doing something :p



$fLoc = $_SERVER['PHP_SELF'];
$fLocExp = explode("/", $fLoc);
$fLocKey = array_keys($fLocExp);
$fLocLastKey = end($fLocKey);

echo "full: " .$fLoc . "<br />";
echo "subdir: " . $fLocExp[$fLocLastKey - 1] . "<br />";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum