Home > php教程 > php手册 > php url字符串截取路径的文件名和扩展名

php url字符串截取路径的文件名和扩展名

WBOY
Release: 2016-06-13 11:37:43
Original
913 people have browsed it

php url字符串截取路径的文件名和扩展名

function retrieve($url)
{
preg_match('/\/([^\/]+\.[a-z]+)[^\/]*$/',$url,$match);
return $match[1];
}

function getExt($url)
{
$path=parse_url($url);
$str=explode('.',$path['path']);
return $str[1];
}
echo getExt('http://www.bkjia.com//fg.php?id=1');
?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template