Return to Snippet

Revision: 8395
at September 18, 2008 10:57 by plindsay


Initial Code
function getParentDirName($path = null) {

	if (!isset($path)) $path = $_SERVER['PHP_SELF'];
	$dir_path = dirname($path);
	
	if (ereg('/', $dir_path)) {
		$dir_path_bits = array_reverse(explode('/', $dir_path));
		return $dir_path_bits[0];
	} else {
		return $dir_path;
	}
}

Initial URL


Initial Description
retrieve the name of the parent directory

Initial Title
getParentDirName()

Initial Tags


Initial Language
PHP