I have an array of numbers ranging from 0-23, each number representing the time from midnight to 11PM. It's ordered descending by the key's value.
22 => int 8
3 => int 7
5 => int 6
etc. If, for example, the array's first element's key is 22 I'd like the variable $first to be "10PM".
Sure, I could write:
if(key($array)=='22'){
$first = '10PM';
}
but I'd have to do that 23 times for each key...is there an easier way?