In PHP, what would be the cleanest way to get the parent directory of the current running script relative to the www root? Assume I have:
$_
This is a function that I use. Created it once so I always have this functionality:
function getDir(){
$directory = dirname(__FILE__);
$directory = explode("/",$directory);
$findTarget = 0;
$targetPath = "";
foreach($directory as $dir){
if($findTarget == 1){
$targetPath = "".$targetPath."/".$dir."";
}
if($dir == "public_html"){
$findTarget = 1;
}
}
return "http://www.".$_SERVER['SERVER_NAME']."".$targetPath."";
}