Forum Moderators: coopster
$path = '/blah/elephant/spaghetti/page.php';
$dirs = explode('/', dirname($path));
/* returns...
Array
(
[0] =>
[1] => blah
[2] => elephant
[3] => spaghetti
)
*/
Also, if this truly will be a url, you may want to have a look at parse_url() [php.net].
And hey Lawbreak, welcome to WebmasterWorld!
$dirs=explode('/',pathname($url));
you could do something like
$dirs=explode('/',substr(pathname($url),1));
then print_r($dirs) would give you
Array
(
[0] => blah
[1] => elephant
[2] => spaghetti
)
But then to find out the number of levels just do
$levels=count($dirs);