[SOLVED] File Extension
Moderator: General Moderators
- kevin_javia
- Forum Newbie
- Posts: 15
- Joined: Mon May 24, 2004 9:46 am
- Location: India
- Contact:
File Extension
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.
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.
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
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";-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
- kevin_javia
- Forum Newbie
- Posts: 15
- Joined: Mon May 24, 2004 9:46 am
- Location: India
- Contact:
File Extension [SOLVED]
Thanks a lot.
Kevin.
Kevin.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm