Published in: PHP
Comments
Subscribe to comments
You need to login to post a comment.
Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.
frankyfish on 04/13/07
6 people have marked this snippet as a favorite
basicmagic
vali29
hudge
heinz1959
benrasmusen
jonhenshaw
Published in: PHP
Subscribe to comments
You need to login to post a comment.
Think what you meant was $i>=0; which works not $i>0;
$path = "";
for($i=count(arraypop(explode("/",dirname($SERVER['PHP_SELF'])))); $i>=0; $i--) $path .= "../";
echo $path;
Thank you very much.
I was not able to get DOCUMENT_ROOT or any other server variables. All was returning empty.
I used this and it's working. I modified
$path = ""; for($i=count(explode("/",dirname($SERVER['PHPSELF']))); $i>1; $i--) $path .= "../"; echo $path;
this works from root folder itself and any level of subfolders
Thanks again