Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a File path

Status
Not open for further replies.

Jring04

Programmer
Jun 25, 2008
2
US
Hi!

I need to find the directory path for a slink file and mkpath the same somewhere else. If /Dir1/Dir2/Dir3/SLink is the actual path, I need to fetch /Dir1/Dir2/Dir3 and create a directory structure (I do not want to make a separate Slink folder) inside another path.

How do I do this?

Thank you in advance.
 
Hi jring,

You need to have a look at the dirname() and basename() functions.

dirname() returns the directory portion of a full path, like this

$d = dirname('/some/path/or/other/to/a/file');

then $d will contain '/some/path/or/other/to/a/'

basename works the other way around

$f = basename('/some/path/or/other/to/a/file');

$f will contain 'file'.


Mike

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top