I have very little knowledge of php. I am trying to put together a very simple script everything is working it is very short and simple however. I am utilizing a get function to pull images from a website. I would like to only get the image/images if it is older then 15 minutes. My current code is <?php $weatherradar = file_get_contents('http://radar.weather.gov/Conus/Loop/northeast_loop.gif'); $fp = fopen('image.gif', 'w'); fwrite($fp, $weatherradar); fclose($fp); ?> PHP: Now It should be a simple bit of code to use but I have know idea of what the code would be, any help would be greatly appreciated. Basically I just want to only get and replace the image if it is older then 15 minutes. Thanks in advance for any help.
<? $fn = 'image.gif'; if (!file_exists($fn) || filemtime($fn) + 15*60 < time()) { //insert get file code here } ?> PHP:
thanks a lot, you saved me a great deal of time believe it or not. It is not that I am too lazy to look it up it just takes forever to find what you are actually looking for. Thanks again