Dynamic Relative Paths
Posted: Tue Feb 01, 2005 3:49 pm
I've been working on a script today to calculate dynamic relative paths.
Does anybody know of a better way to do this than what I've done? Is there a built in function I don't know about? Do you think this will work to attach $link_path to the front of my links? It seems to be working in my tests. What do you all think?
Code: Select all
//Calculate correct relative paths
if (substr_count( $_SERVERї'REQUEST_URI'], '/') != 1)
{
$relative_path ='';
for($x=0;$x < substr_count( $_SERVERї'REQUEST_URI'], '/') -1; $x++)
{
$relative_path .= '../';
}
$link_path = $relative_path;
}