note 23718 added to function.substr-count

From: Date: Thu, 25 Jul 2002 18:10:26 +0000
Subject: note 23718 added to function.substr-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-33561@lists.php.net to get a copy of this message
I was tryin to find a way to find relative path back to Doc Root to post pictures form one script called form multiple pages in a site, so I wrote this. A little bit clumsy but works: $callfrom=$PHP_SELF; // included in file calling the script before an include command $count=substr_count ($callfrom, '/'); $pathtoroot=''; $x=1; while ($x<$count){$pathtoroot='../'.$pathtoroot;$x=++$x;} EG if the calling document was whatver.com/foo/bar/php/index.php then the $roottopath = ../../../ -- http://www.php.net/manual/en/function.substr-count.php http://master.php.net/manage/user-notes.php?action=edit+23718 http://master.php.net/manage/user-notes.php?action=delete+23718 http://master.php.net/manage/user-notes.php?action=reject+23718

« previous php.notes (#33561) next »