Close Panel
Hello Guest! | Log In


lheader.gif rheader.gif
tgcontentlogo.gif
tgcontentlogob.gif

PHP: Get File Extension

There are many ways to get the file extension of a file. Here is an example of a php function I found to do just that.

<?php
function file_extension($fname)
{
$path_info = pathinfo($fname);
return $path_info[‘extension’];
}
?>

Another way would be to check the actual string and use what’s after the last slash. I picked this up on a forum I visit.

<?php
$filetype = substr($file, strrpos($file, ‘.’) + 1);
?>

2 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


23 user(s) currently browsing site (0 members, 23 guests, 0 anonymous)
No Members Logged In


Warning: Cannot modify header information - headers already sent by (output started at /home/tg007net/public_html/blog/wp-content/themes/tg007/header.php:3) in /home/tg007net/public_html/scriptsocket/roomlist.php on line 2
12 Users in IRCommunity
inføвøт, err0r, «Chãin™», ♥fiestýβสbỳ♥, båbyġurł, Enya, Spike1506, Timeless, «·Ħåĺø·», ﴾Ɣ﴿ⓨⓢⓣⓘⓒ★§ⓟⓔⓛⓛ, danger , [☠] Ƙʀʏᴘтιӿ [☠]



lhfooter.gif
Valid XHTML 1.0 | Valid CSS | Load Time: 0.272078 sec(s)
rfooter.gif

Strict Standards: is_a(): Deprecated. Please use the instanceof operator in /home/tg007net/public_html/blog/wp-includes/script-loader.php on line 725

Strict Standards: is_a(): Deprecated. Please use the instanceof operator in /home/tg007net/public_html/blog/wp-includes/script-loader.php on line 597