php gets the file name
Copy code The code is as follows:
function retrieve($url)
{
preg_match ('//([^/]+.[a-z]+)[^/]*$/',$url,$match);
return $match[1];
}
php gets the file extension
Copy code The code is as follows:
function getExt($url)
{
$path=parse_url($url);
$str=explode('.',$path['path']);
return $str[1 ];
}
echo getExt('http://tools.jb51.net/abc/de/fg.php?id=1');
?>
http://www.bkjia.com/PHPjc/321203.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321203.htmlTechArticlephp gets the file name and copies the code as follows: function retrieve($url) { preg_match('//([^ /]+.[a-z]+)[^/]*$/',$url,$match); return $match[1]; } php gets file extension copy code...