3v4l.org

run code in 300+ PHP versions simultaneously
<?php function build_sorter($key) { return function ($a, $b) use ($key) { if ($a[$key] == $b[$key]) { return 0; } return ($a[$key] < $b[$key]) ? -1 : 1; }; } $array = array('123' => array('1'=> 2, 'balance_USD' => -1), '12' => array('1'=> 2, 'balance_USD' => 12),); usort($array, $this->build_sorter('balance_USD')); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SKJMm
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        FETCH_THIS                                       $2      
          4        INIT_METHOD_CALL                                         $2, 'build_sorter'
          5        SEND_VAL_EX                                              'balance_USD'
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   13     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function build_sorter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SKJMm
function name:  build_sorter
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSKJMm%3A4%240'
          2        BIND_LEXICAL                                             ~1, !0
    9     3      > RETURN                                                   ~1
   10     4*     > RETURN                                                   null

End of function build_sorter

Function %00%7Bclosure%7D%2Fin%2FSKJMm%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SKJMm
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $a, !1 = $b, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    5     3        FETCH_DIM_R                                      ~3      !0, !2
          4        FETCH_DIM_R                                      ~4      !1, !2
          5        IS_EQUAL                                                 ~3, ~4
          6      > JMPZ                                                     ~5, ->8
    6     7    > > RETURN                                                   0
    8     8    >   FETCH_DIM_R                                      ~6      !0, !2
          9        FETCH_DIM_R                                      ~7      !1, !2
         10        IS_SMALLER                                               ~6, ~7
         11      > JMPZ                                                     ~8, ->14
         12    >   QM_ASSIGN                                        ~9      -1
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~9      1
         15    > > RETURN                                                   ~9
    9    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSKJMm%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.26 ms | 1400 KiB | 17 Q