3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['val1', 'val2', 200, 179, 230, 234, 242]; $order = [230, 234, 242, 179, 100]; $keyedOrder = array_flip($order); // for efficiency usort($array, function($a, $b) use ($keyedOrder) { return [$keyedOrder[$a] ?? -1, $a] <=> [$keyedOrder[$b] ?? -1, $b]; }); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pa62e
function name:  (null)
number of ops:  16
compiled vars:  !0 = $array, !1 = $order, !2 = $keyedOrder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
    7     6        INIT_FCALL                                               'usort'
          7        SEND_REF                                                 !0
          8        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          9        BIND_LEXICAL                                             ~7, !2
   11    10        SEND_VAL                                                 ~7
    7    11        DO_ICALL                                                 
   12    12        INIT_FCALL                                               'var_export'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > 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/pa62e
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $keyedOrder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    8     3        FETCH_DIM_IS                                     ~3      !2, !0
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      -1
          6        INIT_ARRAY                                       ~5      ~4
          7        ADD_ARRAY_ELEMENT                                ~5      !0
   10     8        FETCH_DIM_IS                                     ~6      !2, !1
          9        COALESCE                                         ~7      ~6
         10        QM_ASSIGN                                        ~7      -1
         11        INIT_ARRAY                                       ~8      ~7
         12        ADD_ARRAY_ELEMENT                                ~8      !1
         13        SPACESHIP                                        ~9      ~5, ~8
         14      > RETURN                                                   ~9
   11    15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
123.59 ms | 1001 KiB | 16 Q