<?php
function replaceExtension($subject, $search = ['.jpeg', '.jpg'], $replace = ['.png'])
{
return str_replace($search, $replace, $subject);
}
$tests = [
'http://a3.mzstatic.com/us/r30/Purple4/v4/cc/74/5c/cc745cd5-9276-71ce-aaf2-0a4b380a2a1c/screen320x320.jpeg',
'http://is1.acf-7e2e-fe9b-4f2d-19019cbce528/mzl.vtyihyzd.png/0x0ss-85.jpg',
'https://itunes.apple.com/ru/developer/mail.ru-games/id566278107?ign-mpt=uo%3D4',
'https://itunes.apple.com/ru/developer/mail.ru-games/id566278107?ign-mpt=uo%3D4.png',
];
foreach ($tests as $test) {
echo replaceExtension($test), PHP_EOL;
}
preferences:
49.25 ms | 402 KiB | 5 Q