3
How to get clean file / image name with extension from the URL in PHP?
How to get clean file name / image name with extension from the URL with PHP?
$reg = '/(?<=jpg|png|gif|jpeg).*/';
$url = 'https://example.com/2012/12/zoe.jpg?w=600&h=400&crop=1,"; "=""';
$rep = '';
$result = preg_replace($reg, $rep, $url);
$cleanfile = basename($result);
echo $cleanfile;
Interserver | Standard & VPS Cloud Hosting | $2.50 /Month
Flexible VPS hosting platform to deploy your online projects.
Economical and balanced between processor cores, memory and storage
rated 3 times
(3)
(0)
comments: 0 / hits: 2151
/ 5 years ago, mon, dec 4, 17, 05:57:17
More From
» PHP
Comments
There are no comments for this Snippet yet