PHP从URL中获取文件名和后缀等信息

getBaseNameByUrl($url);
var_dump(info);
public function getBaseNameByUrl($url) {
        $arr = parse_url($url);
        $arr2 = pathinfo($arr['path']);
        return $arr2;
    }

结果

array(4) { ["dirname"]=> string(34) "/s/files/1/0581/5477/8799/products" ["basename"]=> string(26) "618PJr0UkMS._AC_SL1500.jpg" ["extension"]=> string(3) "jpg" ["filename"]=> string(22) "618PJr0UkMS._AC_SL1500" }

你可能感兴趣的:(php)