Hi
I am trying to calculate how far into a directory structure I am so that I 
can include images and include files without having to hard code them.
I need to turn $PHP_SELF which could be /admin/emails/index.php into ../../ 
which I can then use to get to any directory from root.
like IMG src=<?echo $relative_root?>images/logo.png
Regular expressions leave me cold but I have come up with the following 
monster which works

$relative_root = preg_replace("<\/[[:alnum:]]+>","../", 
preg_replace("</[[:alnum:]]+$>","",strtok($PHP_SELF,".")));

Anybody have a better solution?
Thanks for any help.
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to