ok, this is what you asked for
<?php
function depth()
{
global $PHP_SELF;
$count = count_chars($PHP_SELF);
for($c = 0; $c < $count[ord('/')]; $c++)
$return[] = "..";
if (isset($return))
return implode('/', $return);
}
echo "
<img src='". depth() ."/image/back.gif'>
";
?>
but why cant you just do this.
echo "
<img src='/image/back.gif'>
";
--
Chris Lee
[EMAIL PROTECTED]
"Harshdeep S Jawanda" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Hi all,
To explain my problem, I'll have to draw a directory structure (please
bear with me :-):
<web-server-document-root>
|
+--<dir:common-pics>
|
+--<dir:sub-dir1>
| |
| +--<dir:sub-sub-dir1>
|
+--<dir:sub-dir2>
|
+--<dir:sub-sub-dir2>
| |
| +--<dir:sub-sub-sub-dir1>
|
+--<dir:sub-sub-dir3>
The directory <common-pics> contains some pictures that will be common
to the whole site. I want to use purely relative links, of the form
../../../<common-pics>/pic1.gif (for files in the directory
<sub-sub-sub-dir1>), to link to these common images (this link will be
../../<common-pics>/pic1.gif for <sub-sub-dir1>, <sub-sub-dir2> and
<sub-sub-dir3> etc.).
How can I (essentially) determine the depth of a document wrt the
document root? Basically, I want to have a funtion (say, findDepth())
that I can use to write out my image tags in the following form:
<img src="<?echo findDepth();?>/<common-pics>/pic1.gif">
which will produce the correct number of double-dot-slash (../)
strings.
What help can PHP offer me - i.e., how can I write my hypothetical
findDepth() function? Please help!!
COROLLARY 1:
If the hypothetical function findDepth() returns the appropriate
string, does it _need_ to be echoed or will just putting
<?findDepth();?> in the correct place work?
Thanks!
--
Regards,
Harshdeep Singh Jawanda.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]