2

I have an array with arrays. The arrays contain 6 values including a unique id, date and time. So:

$array=[[$unique_id,$var2,$var3,$date,$time,$var6],[$unique_id,$var2,$var3,$date,$time,$var6],[$unique_id,$var2,$var3,$date,$time,$var6]];

I want to sort the arrays based on date and time, in descending order, displaying the most recent set first. For example assume the following values:

$array[1]=[1,$var2,$var3,27-02-2018,14:05,$var6]
$array[2]=[2,$var2,$var3,28-02-2018,10.50,$var6]
$array[3]=[3,$var2,$var3,28-02-2018,13.30,$var6]

The desired output is:

$sorted_array[1]=[3,$var2,$var3,28-02-2018,13.30,$var6]
$sorted_array[2]=[2,$var2,$var3,28-02-2018,10.50,$var6]
$sorted_array[3]=[1,$var2,$var3,27-02-2018,14:05,$var6]

Any thoughts? Should I combine the $date and $time to a single datetime variable for example? But still how would this work when sorting across the arrays?

Ilse
  • 329
  • 2
  • 6
  • 12

0 Answers0