[PHP] Checking file existence

2006-11-15 Thread Ashley M. Kirchner
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

Re: [PHP] Checking file existence

2006-11-15 Thread Jürgen Wind
Ashley M. Kirchner wrote: 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

Re: [PHP] Checking file existence

2006-11-15 Thread Jürgen Wind
sorry, clicked on send too fast ;) i'd extract the minues and seconds , generate an array of timestamps and sort that array desc -- View this message in context: http://www.nabble.com/Checking-file-existence-tf2636778.html#a7359891 Sent from the PHP - General mailing list archive at

Re: [PHP] Checking file existence

2006-11-15 Thread Jochem Maas
one solution could probably be made using: glob(), sort() and/or filemtime(). btw: I assume your aware that the filenames are not very unique (i.e. twice a day, everyday a given file will potentially be overwritten) and that this is intentional Ashley M. Kirchner wrote: I have files that

Re: [PHP] Checking file existence

2006-11-15 Thread Ashley M. Kirchner
Edward Kay wrote: Are all the files called file..jpg or could they have other names such as clouds.1123.jpg, field.2034.jpg etc? They are all the same exact file name with the only difference being the timestamp. Alternatively, you could get the OS to do the work through an exec call

RE: [PHP] Checking file existence

2006-11-15 Thread Brad Fuller
($img_array); /UntestedCode -Original Message- From: Ashley M. Kirchner [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:19 AM To: PHP General List Subject: [PHP] Checking file existence I have files that are named in the following manner: file..jpg

RE: [PHP] Checking file existence

2006-11-15 Thread Brad Fuller
[mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:56 AM To: php-general@lists.php.net Subject: RE: [PHP] Checking file existence UntestedCode $img_array = array(); $i = 0; while(count($img_array) 5) { $hhmm = date(Hi, strtotime(-$i minutes)); $filename = file

RE: [PHP] Checking file existence

2006-11-15 Thread Edward Kay
: Ashley M. Kirchner [mailto:[EMAIL PROTECTED] Sent: 15 November 2006 15:19 To: PHP General List Subject: [PHP] Checking file existence 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

RE: [PHP] Checking file existence

2006-11-15 Thread Edward Kay
Surely it would be simpler to store all this info in a database table? e.g. id : int created : timestamp filename : varchar Only files that actually existed would be in the DB, plus you could do all your sorting on the 'created' timestamp column. Querying the DB should be much simpler

RE: [PHP] Checking file existence

2006-11-15 Thread John Pillion
[mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:56 AM To: php-general@lists.php.net Subject: RE: [PHP] Checking file existence UntestedCode $img_array = array(); $i = 0; while(count($img_array) 5) { $hhmm = date(Hi, strtotime(-$i minutes)); $filename

Re: [PHP] Checking file existence

2006-11-15 Thread Ashley M. Kirchner
Stut wrote: mall, minor, insignificant point If I have less than 5 files this loop will never end. But you all knew that right? Yup. I break out of the loop if $i reaches 10 for some weird reason. Also, depending on the frequency of files (i.e. are there months-worth of gaps or

Re: [PHP] Checking file existence

2006-11-15 Thread tedd
At 8:18 AM -0700 11/15/06, Ashley M. Kirchner wrote: 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

Re: [PHP] Checking file existence

2006-11-15 Thread Stut
John Pillion wrote: Very nifty Brad, One addition though, so she/you can work back from any point: MoreUntestedCode $i = 0; $start = strtotime(2006-10-05 12:05am); while(count($img_array) 5) { $year = date(Y, strtotime(-$i minutes, $start)); $month= date(m, strtotime(-$i