On Sat, 2007-04-21 at 00:11 +0200, Tijnema ! wrote: > On 4/17/07, Richard Lynch <ceo@xxxxxxxxx> wrote: > > On Sun, April 15, 2007 2:20 pm, Otto Wyss wrote: > > > I want to sort directories according there modification time and > > > thought > > > accociative arrays would be perfect. But when I add an element like > > > > > > $dirs = array (filemtime($d) => $d) > > > > > > the previous ones are lost. I tried array_push but that doesn't seems > > > to > > > work, at least I always get syntax errors. Next try was > > > array_merge(array (...)). So what next? > > > > Two files may have the same modification time. > > > > You are storing only ONE file for any given timestamp. > > > > You could do something like this: > > > > foreach($files as $file){ > > $dirs[filemtime($file)][] = $file; > > } > > > > You will then have an ARRAY for each timestamp with all the files that > > were modified at that time. > > So you end up with a big useless array? How big is the chance that > there are 2 files modified at the same time? 0.00001? or is it > 0.0000000001? Depends on how the files are used, frequency of modification, number of concurrent processes that may modify them, etc, etc. Probably for all we know may be as high as 1.0 in any given second. The resolution of filemtime() is in seconds, I consider that a low enough resolution to worry about possible timestamp collisions. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php