3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array( [ "unix" => 1556547761, // notice the two duplicate unix values "random" => 4 ], [ "unix" => 1556547761, "random" => 2 ], [ "unix" => 1556547769, "random" => 5 ], [ "unix" => 1556547765, // this should be in the 3rd position "random" => 9 ] ); function cmpByUnix($a, $b) { return $a["unix"] - $b["unix"]; } usort($array, "cmpByUnix"); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tDfdM
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   26     1        INIT_FCALL                                                   'usort'
          2        SEND_REF                                                     !0
          3        SEND_VAL                                                     'cmpByUnix'
          4        DO_ICALL                                                     
   28     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function cmpbyunix:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tDfdM
function name:  cmpByUnix
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   23     2        FETCH_DIM_R                                          ~2      !0, 'unix'
          3        FETCH_DIM_R                                          ~3      !1, 'unix'
          4        SUB                                                  ~4      ~2, ~3
          5      > RETURN                                                       ~4
   24     6*     > RETURN                                                       null

End of function cmpbyunix

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.17 ms | 2327 KiB | 15 Q