get file extension


/ Published in: PHP
Save to your folder(s)

get file extension


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.