Get Relative Root

$root = $_SERVER['DOCUMENT_ROOT'];
$root_dir = dirname(dirname(__FILE__));
$root_dir = str_replace ('\\', '/', $root_dir);

function get_relative_home($home_dir, $doc_root){
	$pattern = '/(.*)(' . str_replace('/', '\/', $doc_root) . ').*/';
	preg_match($pattern, $home_dir, $matchs);
	return substr($home_dir, strlen($matchs[1]) + strlen($matchs[2]));
}
define("HOME_REL", get_relative_home($root_dir, $root));