Skip to content

Instantly share code, notes, and snippets.

@yourtion
Created December 25, 2013 09:36
Show Gist options
  • Select an option

  • Save yourtion/8121744 to your computer and use it in GitHub Desktop.

Select an option

Save yourtion/8121744 to your computer and use it in GitHub Desktop.
PHP文件名、扩展名 From http://www.jb51.net/article/21878.htm
//php获取文件扩展名
function getExt($url)
{
$path=parse_url($url);
$str=explode('.',$path['path']);
return $str[1];
}
function retrieve($url)
{
//文件名
preg_match('/\/([^\/]+\.[a-z]+)[^\/]*$/',$url,$match);
return $match[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment