Jump to content

Getting Current Folder


Lamez

Recommended Posts

How would I get the current folder of which my website is in? Pretty much, how would I edit $_SERVER['REQUEST_URI'] to show the last folder?

 

Exmaple

 

if REQUEST_URI = /folder1/another_folder/page.php

 

how would I get /folder1 ?

 

As suggested, you may do this:

$location = '/folder1/another_folder/page.php';
$basedir = explode('/', $location);

echo $basedir[1]; //Output: folder1

 

It will work on any length url, it simply gets the first folder.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.