Closed Thread Icon

Preserved Topic: $DOCUMENT_ROOT??? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21207" title="Pages that link to Preserved Topic: $DOCUMENT_ROOT??? (Page 1 of 1)" rel="nofollow" >Preserved Topic: $DOCUMENT_ROOT??? <span class="small">(Page 1 of 1)</span>\

 
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-15-2001 02:35

I was wondering if there was a way to get the name of a directory into a PHP script without actually knowing the name of it? For example, if I have a bunch of sports teams, and each team has it's own directory, with the directory name being the teams name. Each directory will have it's own index page. I want to be able to access the directory name from within the script to be able to derive the teams name from it.

I hope I have explained myself well enough.

Thanks
-Butcher-

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-15-2001 04:09

getcwd() will get the current working directory from the root of the server


$temp = substr(getcwd(), "/"); get the index of the last slash (may need to reverse the slash

substr($temp); should return the string you want.

sorry max can probably do this in one line with a regexp I just suck at them





:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-15-2001 05:32

Thanks Bitdamaged

That will do just fine!!

And, I think everybody Except mr.maX sucks at regex's. I know I'm having an awful time trying to learn them.

-Butcher-



[This message has been edited by butcher (edited 12-15-2001).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 12-15-2001 12:32

Under Windows use this:

preg_match("/[^\\\]+$/", getcwd(), $match);

Under every other OS use this:

preg_match("/[^\\/]+$/", getcwd(), $match);

After that $match[0] will contain last folder name...


butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-15-2001 22:21

Thanks maX!

That's great.

I appreciate it greatly

-Butcher-

« BackwardsOnwards »

Show Forum Drop Down Menu