Re: Sorting times (SOLVED)

From: Date: Sun, 15 Feb 2009 03:31:18 +0000
Subject: Re: Sorting times (SOLVED)
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-288276@lists.php.net to get a copy of this message
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@gmail.com > > > 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

« previous php.general (#288276) next »