I have an array of numbers ranging from 0 to 23, each number represents a time from midnight to 11pm. It sorts by the key's value in descending order.
22 => int 8 3 => int 7 5 => int 6
etc. For example, if the key of the first element of the array is 22, I want the variable $first to be "10PM".
Of course, I can write:
if(key($array)=='22'){ $first = '10PM'; }
But I have to do it 23 times for each key... Is there an easier way?
I just copied it wrong
I understand
This is the code