PHP gets the filename and extension of the url string interception path
- 2020-03-31 20:16:09
- OfStack
PHP gets the file name
PHP gets the file extension
function retrieve($url)
{
preg_match('//([^/]+.[a-z]+)[^/]*$/',$url,$match);
return $match[1];
}
PHP gets the file extension
<?php
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');
?>