Skip to content

Instantly share code, notes, and snippets.

@patricklewis
Created August 12, 2008 12:59
Show Gist options
  • Save patricklewis/5035 to your computer and use it in GitHub Desktop.
Save patricklewis/5035 to your computer and use it in GitHub Desktop.
<?php
function get_top_directory()
{
# get directory structure eg "/music/graduate/concerts"
$directoryPath = dirname($_SERVER['PHP_SELF']);
# put each directory into an array
$directoryArray = explode('/', $directoryPath);
# get the top level directory
$topDirectory = max($directoryArray);
return $topDirectory;
}
?>
<img src="http://omniupdate.cc.binghamton.edu/images/siteLogos/logo-<?= get_top_directory(); ?>.gif" alt="Binghamton University, State University of New York" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment