Return to Snippet

Revision: 49335
at July 20, 2011 07:37 by BilalELMoussaoui


Updated Code
/*
  * get the extension of file
  * @param : String file name
  * @return : String file extension
  */

function get_extension($file) {
    if (function_exists("pathinfo")) {
        $extension = pathinfo($file, PATHINFO_EXTENSION);
    } else {
        $extension = end(explode(".", $file));
    }
    return trim(strtolower($extension));
}

Revision: 49334
at July 20, 2011 07:36 by BilalELMoussaoui


Initial Code
/*
     * get the extension of file
     * @param : String file name
     * @return : String file extension
     */

    function get_extension($file) {
        if (function_exists("pathinfo")) {
            $extension = pathinfo($file, PATHINFO_EXTENSION);
        } else {
            $extension = end(explode(".", $file));
        }
        return trim(strtolower($extension));
    }

Initial URL

                                

Initial Description
get file extension

Initial Title
get file extension

Initial Tags
php, file

Initial Language
PHP