how to get filename from complete path

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

how to get filename from complete path

Post by eshban »

Hello I have a following string in a variable

Code: Select all


C:\\Inetpub\\check.htm 
How an i extract a filename from that. I just need check.htm from this whole string, or i just need the filename.
a
please help in this manner.

Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Take a look at the functions described at http://de2.php.net/ref.filesystem
dimovi
Forum Newbie
Posts: 7
Joined: Wed Nov 22, 2006 11:29 pm
Location: Austin, TX, USA
Contact:

Re: how to get filename from complete path

Post by dimovi »

eshban wrote:Hello I have a following string in a variable

Code: Select all


C:\\Inetpub\\check.htm 
How an i extract a filename from that. I just need check.htm from this whole string, or i just need the filename.
a
please help in this manner.

Thanks

Code: Select all

// use
$fileName = end(explode('\\', "C:\\Inetpub\\check.htm"));
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: how to get filename from complete path

Post by John Cartwright »

dimovi wrote:

Code: Select all

// use
$fileName = end(explode('\\', "C:\\Inetpub\\check.htm"));
Perhaps if y ou read the manual page provided by volka, you'd come to terms with basename() ;)
Post Reply