Posted By

BilalELMoussaoui on 07/20/11


Tagged

get php file extensipn


Versions (?)

get file extension


 / Published in: PHP
 

get file extension

  1. /*
  2.   * get the extension of file
  3.   * @param : String file name
  4.   * @return : String file extension
  5.   */
  6.  
  7. function get_extension($file) {
  8. if (function_exists("pathinfo")) {
  9. $extension = pathinfo($file, PATHINFO_EXTENSION);
  10. } else {
  11. $extension = end(explode(".", $file));
  12. }
  13. return trim(strtolower($extension));
  14. }

Report this snippet  

You need to login to post a comment.