Quick Tip: Find File Extension In PHP

Posted April 22, 2009 @ 4:21pm by Phil

This simple function determines the file extension from the given filename.

<?php
  function file_extension ($filename)
  {
    return preg_replace('/^.*\./', '', $filename);
  }
?>

Download Source: file_extension.php

Tags: PHP/MySQL, Quick Tip