3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sort_custom(&$array) { $hierarchy = array_flip([ "organization", "company", "group", "unit", "sub_unit", "team" ]); uksort($array, fn($a, $b) => $hierarchy[$a] <=> $hierarchy[$b]); } $array = [ "team" => "team1", "organization" => "organization1", "group" => "group1" ]; sort_custom($array); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MF7X6
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'sort_custom'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   23     4        INIT_FCALL                                               'var_export'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function sort_custom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MF7X6
function name:  sort_custom
number of ops:  12
compiled vars:  !0 = $array, !1 = $hierarchy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_flip'
    6     2        SEND_VAL                                                 <array>
    5     3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   14     5        INIT_FCALL                                               'uksort'
          6        SEND_REF                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          8        BIND_LEXICAL                                             ~4, !1
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   15    11      > RETURN                                                   null


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

End of Dynamic Function 0

End of function sort_custom

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.16 ms | 1003 KiB | 17 Q