Finding the depth

From: Date: Thu, 15 Mar 2001 13:29:10 +0000
Subject: Finding the depth
Groups: php.general 
Request: Send a blank email to php-general+get-44021@lists.php.net to get a copy of this message
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.

« previous php.general (#44021) next »