Something like this?
case in_array(substr($rrr['url'],-4), array('.jpg','.png','.gif','.tif')):
case in_array(substr($rrr['url'],-5), array('.tiff')):
Note, that I omit break;
between the case
-expression.
Also cool:
case in_array(pathinfo($rrr['url'], PATHINFO_EXTENSION), array('jpg','png','gif','tif', 'tiff')):
The snippet from the question doesnt work, because its evaluated into (shortened)
(substr($rrr['url'],-4)=='.jpg') || '.png'
This works, but oviously it doesnt make much sense and is very probably not, what is expected.
Update: This solution seems much cleaner. It assumes, that $rrr['url']
is the only interesting here. See comments
switch (pathinfo($rrr['url'], PATHINFO_EXTENSION)):
case 'jpg':
case 'png':
case 'gif':
case 'tif':
case 'tiff':
do_something();
break;
}