Page 1 of 1
File Extension
Posted: Mon Jun 21, 2004 10:53 pm
by kevin_javia
Hi there,
How can I extract the file extension of the file?
I came across mime_content_type() but it gives only file type not file extension.
Can any one help me?
Thanks a ton in advance.
Kevin.
Posted: Mon Jun 21, 2004 10:57 pm
by kettle_drum
Explode the file name by "." and then take the last element of the array you produce:
Code: Select all
$filename = "hello.rar";
$x = explode(".", $filename);
$x = array_reverse($x);
echo $x; #echos "rar";
$filename = "hello.world.text.edited.txt";
$x = explode(".", $filename);
$x = array_reverse($x);
echo $x; #echos "txt";
Posted: Tue Jun 22, 2004 12:20 am
by Illusionist
this was
posted not too long ago...
Also, you might want to try out the forum's
search
Could save some time, and typing!
Posted: Tue Jun 22, 2004 12:22 am
by kettle_drum
Im surprised that there isnt a function in php to get the extension though.
(WOOHOOOO 400!!!!!!!!)
Posted: Tue Jun 22, 2004 12:23 am
by Illusionist
Yeah, that'd be really helpful!
happy 400th!

Posted: Tue Jun 22, 2004 12:25 am
by kettle_drum
Thanks - only 100 more till im a master.....i best start posting!!
</end of rant>
File Extension [SOLVED]
Posted: Tue Jun 22, 2004 2:47 am
by kevin_javia
Thanks a lot.
Kevin.
Posted: Tue Jun 22, 2004 2:51 am
by Illusionist
No Problem! This is waht we are here for8)
Also, Instead of putting "[SOLVED]" in the reply subject, edit you original post and add "[SOLVED]" to that subject!
Posted: Tue Jun 22, 2004 2:52 am
by feyd
or you can wait for a mod to just mark it solved..

Posted: Tue Jun 22, 2004 2:58 am
by Illusionist
If only i were a mod....
