3v4l.org

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


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QjNg7
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'int'
          3        FETCH_DIM_R                                      ~3      !1, 'int'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QjNg7
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'int'
          3        FETCH_DIM_R                                      ~3      !1, 'int'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 1

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

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.14 ms | 1016 KiB | 15 Q