<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>

```
pathinfo()
```
```
```
$path_info = pathinfo('/foo/bar/baz.bill');

echo $path_info['extension']; // "bill"
```
```