Rated an average of 5 stars by 1 person

Get File Extension

Script Details:
Added on February 2, 2011 by Zhay. Last modified February 11, 2011.
Zhay accreditted the script to himself.

Description:
This script gets the file extension from a file name/path.

Tags: extension, file, get, parse, path, retrieve, strip

Instructions:
Just call the function:

<?php
echo file_get_extension('test.php');
?>

Code:

<?php
# Snippet from PHP Share: http://www.phpshare.org

function file_get_extension($filename)
{
    if ((
$pos strrpos($filename'.')) !== false)
    {
        return 
substr($filename$pos 1);
    }
    
    return 
'';
}
?>

Review this PHP Script:

Rating:

Comments:


Login

User:
Pass:

Register

Not a member? Register today and receive the many free benefits of being a member!

Advertisements