I have the following line of code which works on my local machine because the root directory of the server is the same as the root directory of the site.
$directories = explode("/", str_replace($_SERVER['DOCUMENT_ROOT'] . "/", "", getcwd()));
How can I adapt this to work on my remove server where the root directory is several levels below that of the site. I guess I need to only include the site directories rather than the server directories.