3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [1, 2, 3], [1, 3, 5], [1, 2, 4], [0, 2, 3], ]; function one($a, $b) { return $a[0] <=> $b[0] ?: $a[1] <=> $b[1] ?: $a[2] <=> $b[2] ?: 0; } function two($a, $b) { return [$a[0], $a[1], $a[2]] <=> [$b[0], $b[1], $b[2]]; } function three($a, $b) { return $a <=> $b; } usort($array, one(...)); print_r($array); usort($array, two(...)); print_r($array); usort($array, three(...)); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bZ2W3
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        INIT_FCALL                                               'one'
          4        ZEND_CALLABLE_CONVERT                            ~2      
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
   26     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   27    10        INIT_FCALL                                               'usort'
         11        SEND_REF                                                 !0
         12        INIT_FCALL                                               'two'
         13        ZEND_CALLABLE_CONVERT                            ~5      
         14        SEND_VAL                                                 ~5
         15        DO_ICALL                                                 
   28    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   29    19        INIT_FCALL                                               'usort'
         20        SEND_REF                                                 !0
         21        INIT_FCALL                                               'three'
         22        ZEND_CALLABLE_CONVERT                            ~8      
         23        SEND_VAL                                                 ~8
         24        DO_ICALL                                                 
   30    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function one:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bZ2W3
function name:  one
number of ops:  19
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_DIM_R                                      ~2      !0, 0
          3        FETCH_DIM_R                                      ~3      !1, 0
          4        SPACESHIP                                        ~4      ~2, ~3
          5        JMP_SET                                          ~5      ~4, ->10
   12     6        FETCH_DIM_R                                      ~6      !0, 1
          7        FETCH_DIM_R                                      ~7      !1, 1
          8        SPACESHIP                                        ~8      ~6, ~7
          9        QM_ASSIGN                                        ~5      ~8
         10        JMP_SET                                          ~9      ~5, ->15
   13    11        FETCH_DIM_R                                      ~10     !0, 2
         12        FETCH_DIM_R                                      ~11     !1, 2
         13        SPACESHIP                                        ~12     ~10, ~11
         14        QM_ASSIGN                                        ~9      ~12
         15        JMP_SET                                          ~13     ~9, ->17
   14    16        QM_ASSIGN                                        ~13     0
         17      > RETURN                                                   ~13
   15    18*     > RETURN                                                   null

End of function one

Function two:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bZ2W3
function name:  two
number of ops:  17
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_DIM_R                                      ~2      !0, 0
          3        INIT_ARRAY                                       ~3      ~2
          4        FETCH_DIM_R                                      ~4      !0, 1
          5        ADD_ARRAY_ELEMENT                                ~3      ~4
          6        FETCH_DIM_R                                      ~5      !0, 2
          7        ADD_ARRAY_ELEMENT                                ~3      ~5
          8        FETCH_DIM_R                                      ~6      !1, 0
          9        INIT_ARRAY                                       ~7      ~6
         10        FETCH_DIM_R                                      ~8      !1, 1
         11        ADD_ARRAY_ELEMENT                                ~7      ~8
         12        FETCH_DIM_R                                      ~9      !1, 2
         13        ADD_ARRAY_ELEMENT                                ~7      ~9
         14        SPACESHIP                                        ~10     ~3, ~7
         15      > RETURN                                                   ~10
   19    16*     > RETURN                                                   null

End of function two

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

End of function three

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.49 ms | 1018 KiB | 18 Q