Re: Finding the depth

From: Date: Thu, 15 Mar 2001 15:51:27 +0000
Subject: Re: Finding the depth
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-44080@lists.php.net to get a copy of this message
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 lee@mediawaveonline.com "Harshdeep S Jawanda" <harsh@pspl.co.in> wrote in message news:200103151329.f2FDTAl04604@www.pspl.co.in... 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#44080) next »