PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I writing a system that generates a file whenever it's run. Each time it runs it creates a new file. Not a problem. However, I'm also writing something that needs to go and get the last file and open it. Ideally I'd like to do this using the file creation date.. it's recorded so it makes sense to use it. Coding something to do that is pretty trivial:
However .. that isn't exactly scalable. When my system starts having many thousands of files it'll grind to a halt. Is there any method to order the results of glob() so I can just use the first result? Is there a suitable alternative to glob()? I know I could name the files in order and use the filename which would eliminate the call to stat(), but I'd rather not do that as files might eventually come from sources other than those I control.
or you might try storing the name of the latest file generated somewhere so that it's just the matter of reading file name from that location. pretty simple...
Can't capture "ls -t" as the code need to be cross-platform and work in safe mode.
Can't really store the name of the file because people will be uploading them .. I need to be *certain* it's the latest file even if someone has uploaded incorrectly (eg via FTP instead of a web interface).