how to get directory path only without file name in PHP
RegisterLogin
how to get directory path only without file name in PHP
Post Description: how to get directory path only without file name in PHP
Tags: how, to, get, directory, path, only, without, file, name, in, PHP
This Post Was Posted On Oct 07, 2010 By web hosting #1320
Post Description: how to get directory path only without file name in PHP
Tags: how, to, get, directory, path, only, without, file, name, in, PHP
This Post Was Posted On Oct 07, 2010 By web hosting #1320
how to get directory path only without file name in PHP by web hosting
<?
function GetFileDir($php_self){
$filename = explode("/", $php_self); // THIS WILL BREAK DOWN THE PATH INTO AN ARRAY
for( $i = 0; $i < (count($filename) - 1); ++$i ) {
$filename2 .= $filename[$i].'/';
}
return $filename2;
}
echo GetFileDir($_SERVER['PHP_SELF']);
?>
function GetFileDir($php_self){
$filename = explode("/", $php_self); // THIS WILL BREAK DOWN THE PATH INTO AN ARRAY
for( $i = 0; $i < (count($filename) - 1); ++$i ) {
$filename2 .= $filename[$i].'/';
}
return $filename2;
}
echo GetFileDir($_SERVER['PHP_SELF']);
?>
so for example when i do this:
echo $_SERVER['PHP_SELF'];
OUTPUT:
/var/www/myfile.php
but i dont want the myfile.php part of it, i only need /var/www/ part. so to do this you can use the function above and it will return this:
OUTPUT:
/var/www/
thanks for www.webune.com for their support on this.
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2011 Webune Forums - Tue Dec 20, 2011 9:12 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3