I have a list of files in an array where the file name is the key and the value is the last modified date in seconds. They are sorted from oldest to newest.
The glob() 'd in files are then sorted this way using
asort($fileNameToLastModified, SORT_NUMERIC);
I use array_shift () to get the oldest file. Unfortunately, this seems to give me meaning, and there seems to be no way to get the key.
Would there be a single way to do it something like this?
$keys = array_keys($fileNameToLastModified); $oldest = array_shift($keys); array_shift($fileNameToLastModified);
... or is there a built-in method for this?
sorting arrays php
alex
source share