3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'sort' => 'a', 'page' => 'b', 'goo' => 'c', //'search' => 'd', 'topic' => 'e', 'foo' => 'f', 'lng' => 'g', 'poo' => 'h', ]; $lookup = [ 'lng' => 5, 'topic' => 4, 'page' => 3, 'sort' => 2, 'search' => 1, // do not declare a key with a zero value ]; uksort( $input, function($a, $b) use($lookup) { return ($lookup[$b] ?? 0) <=> ($lookup[$a] ?? 0); } ); var_export($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0thJi
function name:  (null)
number of ops:  12
compiled vars:  !0 = $input, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   23     2        INIT_FCALL                                               'uksort'
   24     3        SEND_REF                                                 !0
   25     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   27     6        SEND_VAL                                                 ~4
   23     7        DO_ICALL                                                 
   30     8        INIT_FCALL                                               'var_export'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > 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/0thJi
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $a, !1 = $b, !2 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   26     3        FETCH_DIM_IS                                     ~3      !2, !1
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      0
          6        FETCH_DIM_IS                                     ~5      !2, !0
          7        COALESCE                                         ~6      ~5
          8        QM_ASSIGN                                        ~6      0
          9        SPACESHIP                                        ~7      ~4, ~6
         10      > RETURN                                                   ~7
   27    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.38 ms | 999 KiB | 15 Q