Re: Re: Extracting multi dimensional array value
| From: | Ron Piggott | Date: | Sat, 02 May 2015 16:06:41 +0000 |
| Subject: | Re: Re: Extracting multi dimensional array value | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324849@lists.php.net to get a copy of this message | ||
On 02/05/15 07:29, Christoph Becker wrote:
Ashley Sheridan wrote:In the end I've used // sort newest to oldest translation rsort($array); // extract oldest translation $array=end($array); Thank you very much for your help. RonOn 2 May 2015 11:57:42 BST, Christoph Becker <cmbecker69@gmx.de> wrote:Ron Piggott wrote:Sorting like this would put the earliest date first, and you can't access it by numeric index. Ron is looking for the oldest date, what seems to be the same as the earliest date. Anyhow, otherwise one could use rsort() instead of sort(). Accessing by numeric index is possible after either sorting, because both functions don't keep the keys (contrary to asort() and arsort()): $array = [ 'es-PR' => '2014-11-04 08:22:07', 'en-US' => '2009-04-05 09:00:00', 'es-MX' => '2014-11-08 02:25:40' ]; sort($array); var_dump($array);I have the following array: Array (I suggest you sort() the array, and then access the first element: sort($array); $oldest = $array[0];[es-PR] => 2014-11-04 08:22:07 [en-US] => 2009-04-05 09:00:00 [es-MX] => 2014-11-08 02:25:40) How can I extract the oldest date from it? The language ISO order is going to change randomly.