I have an array with URLs for download:
$urls = array(
'http://ads.320x60.us.dizplayzone.com/1.png',
'http://ads.480x90.us.dizplayzone.com/1.png',
'http://ads.768x120.us.dizplayzone.com/1.png',
'http://ads.900x150.us.dizplayzone.com/1.png',
'http://ads.320x60.us.dizplayzone.com/2.png',
'http://ads.480x90.us.dizplayzone.com/2.png',
'http://ads.768x120.us.dizplayzone.com/2.png',
'http://ads.900x150.us.dizplayzone.com/2.png',
'http://ads.320x60.us.dizplayzone.com/100.png',
'http://ads.480x90.us.dizplayzone.com/100.png',
'http://ads.768x120.us.dizplayzone.com/100.png',
'http://ads.900x150.us.dizplayzone.com/100.png',
'http://ads.320x60.us.dizplayzone.com/200.png',
'http://ads.480x90.us.dizplayzone.com/200.png',
'http://ads.768x120.us.dizplayzone.com/200.png',
'http://ads.900x150.us.dizplayzone.com/200.png',
'http://ads.320x60.us.dizplayzone.com/300.png',
'http://ads.480x90.us.dizplayzone.com/300.png',
'http://ads.768x120.us.dizplayzone.com/300.png',
'http://ads.900x150.us.dizplayzone.com/300.png',
'http://ads.320x60.us.dizplayzone.com/55.png',
'http://ads.480x90.us.dizplayzone.com/55.png',
'http://ads.768x120.us.dizplayzone.com/55.png',
'http://ads.900x150.us.dizplayzone.com/55.png',
'http://ads.320x60.us.dizplayzone.com/12.png',
'http://ads.480x90.us.dizplayzone.com/12.png',
'http://ads.768x120.us.dizplayzone.com/12.png',
'http://ads.900x150.us.dizplayzone.com/12.png');
The width of each of the images is found before the x
.
Now the task is to find those URLs that match a given arbitrary screen resolution the best. So, for instance if the screen resolution is 1920x1080, the array would be shortened to only contain URLs that are 900 pixels wide (ie. http://ads.900x150.us.dizplayzone.com/12.png
, http://ads.900x150.us.dizplayzone.com/55.png
etc.)
If the screen resolution is 320x480 then the array would only contain http://ads.320x60.us.dizplayzone.com/12.png
, http://ads.320x60.us.dizplayzone.com/55.png
etc.)
What I want to mimic is basically the same behaviour as the srcset attribute for image tags in HTML5 using either PHP or Java.
After the array has been shortened the URLs still in the array can then be downloaded.
Can this be done?