3v4l.org

run code in 500+ 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, fn($a, $b) => [$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/qAmLV
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
         10        SEND_VAL                                                     ~7
         11        DO_ICALL                                                     
    8    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/qAmLV
function name:  {closure:/in/qAmLV:7}
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
          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
          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
         15*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.32 ms | 2103 KiB | 15 Q