The function below uses the number of '/' in the path to determine the pages level within a site. I need this value before I can successfully include(); a file. For example, if a file was located at '/folder/folder/folder/file.php' the result would be '../../../'
Code: Select all
function get_dir() {
$path = $_SERVER['PATH_INFO'];
$path = explode("/",$path);
$num_levels = count($path) - 2;
for($i=0;$i<$num_levels;$i++) { $dir.= "../"; }
return $dir;
}A solution is to just place the contents of the function on any page that needs the value but it would be much cleaner to just be able to call the function.
I know that this could be acheived by producing a PHP extension that contained the function but I have no knowledge of how to produce DLL's.
Cheers, Snick