» Birthday Bundle - Over $400 worth of Envato files for just $20

Get filename extension

Posted on July 15, 2008, Filled under PHP,  Bookmark it

This snippet can help you to get the extension of a filename:

<?php
... some code here ...
// Filename
$filename = 'public_html/root/internet.gif';
// Extension
$ext = strrchr($filename, ".");
echo $ext; // will return ".gif"
?>

Do you wish to receive the latest updates as soon as they are posted? Get our RSS Feed or Subscribe to the Newsletter!

Get our RSS Feed!

One Reply to "Get filename extension"

  1. I think,
    It will create a problem when the file name is like “xyx.02.jpg”

Leave a Reply


* = required fields

  (will not be published)


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>

Note: If you want to post CODE Snippets, please make them postable first!
(e.g. <br /> should be converted to &lt;br /&gt;)