How to sort an array of times chronologically?

前端 未结 8 925
梦毁少年i
梦毁少年i 2021-01-17 18:39

I have a non-associative array where the data that comes in is not sorted (I\'m receiving the data from an outside system and cannot force it to come into the array in sorte

相关标签:
8条回答
  • 2021-01-17 19:42

    change your code to this:

    $wedTrackTimes = array_unique($wedTrackTimes);
    sort($wedTrackTimes);
    print_r($wedTrackTimes);
    

    as you can read in the documentation, the return value of sort() is true/1 or false/0 and indicates if sorting was possible or an error occured.

    0 讨论(0)
  • 2021-01-17 19:43

    That's right, sort returns bool. Just use that:

    sort($wedTrackTimes);
    
    0 讨论(0)
提交回复
热议问题