No products in the cart.
Forum Replies Created
Viewing 1 post (of 1 total)
- AuthorPosts
-
sinha
ParticipantSometime url has additional parameters appended to it. In such scenario we can remove the parameter section first and then we can use the PHP’s inbuilt pathinfo() function to get the image name from the url.
$url = 'http://images.fitnessmagazine.mdpcdn.com/sites/story/shutterstock_65560759.jpg?itok=b8HiA95H';
Check if the image url has parameters appended.
if (strpos($url, '?') !== false) { $t = explode('?',$url); $url = $t[0]; }
The resulting url variable now contain
http://images.fitnessmagazine.mdpcdn.com/sites/story/shutterstock_65560759.jpg
Use the pathinfo() to retrieve the desired details.
$pathinfo = pathinfo($url); echo $pathinfo['filename'].'.'.$pathinfo['extension'];
This will give shutterstock_65560759.jpg as output.
- AuthorPosts
Viewing 1 post (of 1 total)