Re: String help needed

From: Date: Thu, 24 Aug 2000 03:35:29 +0000
Subject: Re: String help needed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13291@lists.php.net to get a copy of this message
On 23 Aug, CDitty wrote: > Does anyone have a routine already built that will give you the name of the > current directory? Only the current directory is needed. I don't need the > directory before it or the file that is being called. IE.....If the path > is /refer/yahoo/ , I only need the yahoo. > > I thought about using the various string commands, but I must be too tired > to figure it out. > > This is what I have. > $myPath = $PHP_SELF; > echo $myPath . " - Path<br>"; > echo strlen($myPath) . " - String Length<br>"; > $first = strpos($myPath, ".htm"); > $last = substr($myPath, 7, 1); > echo $first . " - String Pos<br>"; > echo $last . " - Start of Directory name<br>"; > echo strpos($myPath, "index.htm"); > > I have looked over the manual, but like I said, I must be too tired to > figure it out. Anyone? > > TIA dirname() is probably what you want. Then you could play with that to get the bottom level directory. One possibility - reverse the string and grab up to the first slash, then reverse again. Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#13291) next »