Re: Sorting times (SOLVED)

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

 



tedd wrote:
> At 4:15 PM -0500 2/14/09, John Corry wrote:
>> 1. convert the string representation of times to timestamps using
>> strtotime()
>> 2. sort the timestamps
>> 3. display the timestamps as strings using date('format', timestamp)
>>
>> Would that work?
>>
>> John Corry
>> email: jcorry@xxxxxxxxx
> 
> 
> John:
> 
> Bingo -- that worked!
> 
> Thanks.
> 
> tedd
> 
> ---
> 
> Here's the code.
> 
> <?php
> // ====== returns a time array sorted
> 
> function sortTime($in_times)
>     {
>     $time = array();
>     foreach ($in_times as $t)
>         {
>         $time [] = strtotime($t);
>         }
> 
>     sort($time);
> 
>     $sort_time = array();
>     foreach ($time as $t)
>         {
>         $sort_time[] = date('g:ia', $t);
>         }
>     return $sort_time;
>     }
> ?>
> 
> 
Yeah, hif I had known that you wanted a function where you loop through
your array twice, that would have done it.  Bravo.



-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
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