3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array("id"=>3, "name"=>"peter"), array("id"=>1, "name"=>"steve"), array("id"=>5, "name"=>"damian"), array("id"=>9, "name"=>"ethan") ); $compare = function($key, $order = SORT_DESC) { return function($a, $b) use ($key, $order) { if ($order === SORT_ASC) $order = -1; else $order = 1; if (is_numeric($a[$key])) return $order * ($a[$key] - $b[$key]); if (is_string($a[$key])) return $order * strcmp($a[$key], $b[$key]); return 0; }; }; usort($data, $compare("name")); print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1gYY3
function name:  (null)
number of ops:  14
compiled vars:  !0 = $data, !1 = $compare
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1gYY3%3A10%240'
          2        ASSIGN                                                   !1, ~3
   26     3        INIT_FCALL                                               'usort'
          4        SEND_REF                                                 !0
          5        INIT_DYNAMIC_CALL                                        !1
          6        SEND_VAL_EX                                              'name'
          7        DO_FCALL                                      0  $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
   28    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F1gYY3%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1gYY3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $key, !1 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
   11     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1gYY3%3A11%241'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   23     5      > RETURN                                                   ~2
   24     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1gYY3%3A10%240

Function %00%7Bclosure%7D%2Fin%2F1gYY3%3A11%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
Branch analysis from position: 19
filename:       /in/1gYY3
function name:  {closure}
number of ops:  32
compiled vars:  !0 = $a, !1 = $b, !2 = $key, !3 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   12     4        IS_IDENTICAL                                             !3, 4
          5      > JMPZ                                                     ~4, ->8
   13     6    >   ASSIGN                                                   !3, -1
          7      > JMP                                                      ->9
   15     8    >   ASSIGN                                                   !3, 1
   17     9    >   INIT_FCALL                                               'is_numeric'
         10        FETCH_DIM_R                                      ~7      !0, !2
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                         $8      
         13      > JMPZ                                                     $8, ->19
   18    14    >   FETCH_DIM_R                                      ~9      !0, !2
         15        FETCH_DIM_R                                      ~10     !1, !2
         16        SUB                                              ~11     ~9, ~10
         17        MUL                                              ~12     !3, ~11
         18      > RETURN                                                   ~12
   19    19    >   FETCH_DIM_R                                      ~13     !0, !2
         20        TYPE_CHECK                                   64          ~13
         21      > JMPZ                                                     ~14, ->30
   20    22    >   INIT_FCALL                                               'strcmp'
         23        FETCH_DIM_R                                      ~15     !0, !2
         24        SEND_VAL                                                 ~15
         25        FETCH_DIM_R                                      ~16     !1, !2
         26        SEND_VAL                                                 ~16
         27        DO_ICALL                                         $17     
         28        MUL                                              ~18     !3, $17
         29      > RETURN                                                   ~18
   22    30    > > RETURN                                                   0
   23    31*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1gYY3%3A11%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.01 ms | 1400 KiB | 21 Q