title: How to get a file's extension in PHP?
body: <p>This is a question you can read everywhere on the web with various answers:</p>
  
  <pre><code>$ext = end(explode('.', $filename));
  $ext = substr(strrchr($filename, '.'), 1);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
  
  $exts = split("[/\\.]", $filename);
  $n    = count($exts)-1;
  $ext  = $exts[$n];
  </code></pre>
  
  <p>etc.</p>
  
  <p>However, there is always "the best way" and it should be on Stack Overflow.</p>