2016-01-26 14:31:53 +00:00
|
|
|
<?php
|
|
|
|
|
2016-03-16 16:07:22 +00:00
|
|
|
# Returns the extension of the filename (path or URI) or an empty string
|
|
|
|
function getExtension($filename, $isURI = false) {
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-03-16 16:07:22 +00:00
|
|
|
# If $filename is an URI, get only the path component
|
|
|
|
if ($isURI)
|
|
|
|
$filename = parse_url($filename, PHP_URL_PATH);
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-03-16 16:07:22 +00:00
|
|
|
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
if (!empty($extension))
|
|
|
|
$extension = '.' . $extension;
|
2016-01-26 14:31:53 +00:00
|
|
|
|
2016-03-16 16:07:22 +00:00
|
|
|
return $extension;
|
2016-01-26 14:31:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|