Checking file existence

From: Date: Wed, 15 Nov 2006 15:18:48 +0000
Subject: Checking file existence
Groups: php.general 
Request: Send a blank email to php-general+get-244662@lists.php.net to get a copy of this message
I have files that are named in the following manner: file.####.jpg (where #### is an hhmm timestamp [hour and minutes]) What's the best way to take the current hhmm timestamp and run backwards finding the previous 5 files, and checking whether they actually exist? There's a possibility one or more might not exist and rather than returning a blank value, I want to continue further back till I find the next. So for example, say I have: file 1122.jpg file 1121.jpg file 1119.jpg file 1117.jpg file 1116.jpg file 1114.jpg Notice the gaps, 1120, 1118, and 1115 are missing. But I still want to return five, thus 1122, 1121, 1119, 1117, and 1116. I thought of taking the current timestamp and loop five times, subtracting from it every time, but that's assuming all five are there. If one's missing then I only have four images. -- W | It's not a bug - it's an undocumented feature. +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.

« previous php.general (#244662) next »