3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 124 => [ 'releaseDate' => '2020-07-01 00:00:00', 'isNewest' => true, ], 110 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => false, ], 129 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => true, ], 128 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => false, ], 130 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => false, ], 131 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => false, ], 132 => [ 'releaseDate' => '2020-08-15 00:00:00', 'isNewest' => false, ], 123 => [ 'releaseDate' => '2020-07-01 00:00:00', 'isNewest' => false, ], 125 => [ 'releaseDate' => '2020-07-01 00:00:00', 'isNewest' => false, ], 127 => [ 'releaseDate' => '2020-07-01 00:00:00', 'isNewest' => false, ], ]; uasort($array, function ($a, $b) { // if dates not equal, return result of comparison // since dates are in Y-m-d H:i:s format we can compare as strings if (($rdcmp = strcmp($a['releaseDate'], $b['releaseDate'])) != 0) return $rdcmp; // dates are equal, so sort true values first if ($a['isNewest'] && !$b['isNewest']) return -1; elseif (!$a['isNewest'] && $b['isNewest']) return 1; else return 0; }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PNQmR
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   46     1        INIT_FCALL                                               'uasort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   54     4        SEND_VAL                                                 ~2
   46     5        DO_ICALL                                                 
   55     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 17
filename:       /in/PNQmR
function name:  {closure}
number of ops:  30
compiled vars:  !0 = $a, !1 = $b, !2 = $rdcmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   49     2        INIT_FCALL                                               'strcmp'
          3        FETCH_DIM_R                                      ~3      !0, 'releaseDate'
          4        SEND_VAL                                                 ~3
          5        FETCH_DIM_R                                      ~4      !1, 'releaseDate'
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                         $5      
          8        ASSIGN                                           ~6      !2, $5
          9        IS_NOT_EQUAL                                             ~6, 0
         10      > JMPZ                                                     ~7, ->12
         11    > > RETURN                                                   !2
   51    12    >   FETCH_DIM_R                                      ~8      !0, 'isNewest'
         13      > JMPZ_EX                                          ~8      ~8, ->17
         14    >   FETCH_DIM_R                                      ~9      !1, 'isNewest'
         15        BOOL_NOT                                         ~10     ~9
         16        BOOL                                             ~8      ~10
         17    > > JMPZ                                                     ~8, ->20
         18    > > RETURN                                                   -1
         19*       JMP                                                      ->29
   52    20    >   FETCH_DIM_R                                      ~11     !0, 'isNewest'
         21        BOOL_NOT                                         ~12     ~11
         22      > JMPZ_EX                                          ~12     ~12, ->25
         23    >   FETCH_DIM_R                                      ~13     !1, 'isNewest'
         24        BOOL                                             ~12     ~13
         25    > > JMPZ                                                     ~12, ->28
         26    > > RETURN                                                   1
         27*       JMP                                                      ->29
   53    28    > > RETURN                                                   0
   54    29*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.36 ms | 1005 KiB | 16 Q