you can use http://php.net/manual/en/function.pathinfo.php here