Page 1 of 1

how to get filename from complete path

Posted: Tue Dec 19, 2006 5:06 am
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

Posted: Tue Dec 19, 2006 5:21 am
by volka
Take a look at the functions described at http://de2.php.net/ref.filesystem

Re: how to get filename from complete path

Posted: Tue Dec 19, 2006 12:04 pm
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"));

Re: how to get filename from complete path

Posted: Tue Dec 19, 2006 12:24 pm
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() ;)