I am getting the image url from one function. I need to find the extension for the image. Sometimes the image url comes with parameters like http://slimages.macys.com/is/image/MCY/products/4/optimized/1776484_fpx.tif?$filterlrg$&wid=370
. So, the file extension comes like tif?$filterlrg$&wid=370
. How can I get the exact extension.
Below is my code
<?php
$srcimg = 'http://slimages.macys.com/is/image/MCY/products/4/optimized/1776484_fpx.tif?$filterlrg$&wid=370';
$fullpath = basename($srcimg);
$userImageDetails = pathinfo($fullpath);
$extension = strtolower($userImageDetails['extension']);
echo $extension;
?>