Breaking News
Home / Web / PHP / PHP Snippets / How to get file extension in PHP?

How to get file extension in PHP?

  1.         /* Extract the file extension
  2.          *
  3.          * @access      public
  4.          * @param       string
  5.          * @return      string
  6.          */    
  7.         function get_extension($filename)
  8.         {
  9.                 $x = explode(‘.’, $filename);
  10.                 return ‘.’.end($x);
  11.         }      
[pb_builder]

Check Also

How to list files in a directory in PHP?

<?php if ($handle = opendir(‘/path/to/directory’)) {     echo "Directory handle: $handlen";     echo …

Advertisment ad adsense adlogger