Hey Guys!~
I have a question:
I have a directory structure like this:
http://www.root.com/application/script.php
I need to figure out a way to get just the name of the parent folder (not the entire path) of a script. (in above, A quick function that returnd just 'application' would be great!)
This will allow me to define this:
define('CURRENT_APP', need this code...);
this will allow me to dynamically determine which application I am in and will help me redact the code.
What is the best way to do this?
I am familiar with all the functions that return the entire directory path you are in...
THANKS:D
ANDREW
Get just parent folder name
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Get just parent folder name
Something like:
I don't recall if those are all the right function names.
Code: Select all
array_pop(explode('/', dirname($_SERVER['SCRIPT_PATH'])))(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Get just parent folder name
Code: Select all
$path = 'this/is/an/example/file.dat';
$parent = basename(dirname($path));
echo $parent; // Result: example
Re: Get just parent folder name
Good answer arbor ! 5 gold stars...
I didn't think about using explode and array_pop.. pretty simple:)
thanks for your help, It seems like you are always showing me the way.
anybody else has a solution please post it...
Ap
I didn't think about using explode and array_pop.. pretty simple:)
thanks for your help, It seems like you are always showing me the way.
anybody else has a solution please post it...
Ap
Re: Get just parent folder name
thanks Hockey.. even better:)