> Well, it does some sorting, but not quite what I'm after :( > > I've managed to get the list so that all the (sub) entries are sorted in > the correct order. Now its just a matter of finding the highest expire > date for /each/ domain, and delete the other entries for that domain. > So, in the end, all that's left is one entry per domain, with its latest > expire date. > > Hopefully this makes it a bit clearer.
OK, so it's just the other way round - I see. Instead of deleting the entry with the highest expiry date we delete all the others: foreach ($foo as $key => $value) { $tempArray = array(); foreach ($value as $subkey => $subvalue) { // add expires value only to the temporary array for sorting $tempArray[$subkey] = $foo[$key][$subkey]['expires']; } // sort array by value descending arsort($tempArray); /* new stuff starts here */ // remove the entry with the latest expiry (the first array element) array_push($tempArray); // now unset all remaining/not needed entries foreach ($tempArray as $tempKey => $tempValue) { unset($foo[$key][$tempKey]); } } By the way, isn't there a way to filter this stuff BEFORE or WHILE the whole array is created? Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php