I would like to retrieve an image from a given url, i have the filename but the issue i have is that the extension is unknown. It could be either, jpg, gif or png.
This is how i have approached it but doesnt seem to be working:
$extensions = array('jpg', 'png', 'gif');
foreach ($extensions as $ext) {
if (file_exists('https://mytestimage.com/products/3c763dce-666b-4ba9-a05a-cca846391aea/thumb.' . $ext)) {
echo 'Found filename.' . $ext;
break;
}
}
Any suggestions?