Page 1 of 1

Show Filename without Filetype

Posted: Wed Apr 07, 2004 7:32 am
by marce23
Hi!
How can i read in only the filename (without the Filetyp) of a file?
thx
marce23

Posted: Wed Apr 07, 2004 7:57 am
by patrikG
You always only get the filename. The filetype is a different variable in PHP.

If you're refering to the filetype-extension under Windows (e.g. myfile.txt), it's always three letters long and seperated by a dot. Hence you can can either use [php_man]substr[/php_man] and variants or [php_man]explode[/php_man].

Posted: Wed Apr 07, 2004 9:59 am
by marce23
Oh thanks!
The [php_man]substr[/php_man] function is great!
marce23

Posted: Wed Apr 07, 2004 10:06 am
by patrikG
marce23 wrote:Oh thanks!
The [php_man]substr[/php_man] function is great!
marce23
Reading the manual: priceless Image

Posted: Wed Apr 07, 2004 11:05 am
by feyd
It's not always three letters long. pathinfo() is a safer solution.