3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order = [7, 2, 1, 4]; $array = [ 1 => "O", 2 => "T", 4 => "F", 7 => "S" ]; uksort($array, static function (int $key1, int $key2) use ($order): int { return array_search($key1, $order, true) <=> array_search($key2, $order, true); }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uK0m7
function name:  (null)
number of ops:  12
compiled vars:  !0 = $order, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
   12     2        INIT_FCALL                                               'uksort'
          3        SEND_REF                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !0
   14     6        SEND_VAL                                                 ~4
   12     7        DO_ICALL                                                 
   16     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         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/uK0m7
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $key1, !1 = $key2, !2 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   13     3        INIT_FCALL                                               'array_search'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $3      
          8        INIT_FCALL                                               'array_search'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $4      
         13        SPACESHIP                                        ~5      $3, $4
         14        VERIFY_RETURN_TYPE                                       ~5
         15      > RETURN                                                   ~5
   14    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.05 ms | 1005 KiB | 16 Q