Re: Re: Extracting multi dimensional array value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2 May 2015 11:57:42 BST, Christoph Becker <cmbecker69@xxxxxx> wrote:
>Ron Piggott wrote:
>
>> I have the following array:
>> 
>> 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
>> )
>> 
>> How can I extract the oldest date from it?  The language ISO order is
>> going to change randomly.
>
>I suggest you sort() the array, and then access the first element:
>
>  sort($array);
>  $oldest = $array[0];

Sorting like this would put the earliest date first, and you can't access it by numeric index.

Something like this would work though:

$oldest = end($array);

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux