3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr1 = [2, 1, 2, 5, 7, 1, 9, 3, 6, 8, 8]; $arr2 = [2, 1, 8, 3]; $priority = array_flip($arr2); $fallback = count($arr2); usort( $arr1, fn($a, $b) => [$priority[$a] ?? $fallback, $a] <=> [$priority[$b] ?? $fallback, $b] ); var_export($arr1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MrukZ
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $priority, !3 = $fallback
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'array_flip'
          3        SEND_VAR                                                     !1
          4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !2, $6
    7     6        COUNT                                                ~8      !1
          7        ASSIGN                                                       !3, ~8
    9     8        INIT_FCALL                                                   'usort'
   10     9        SEND_REF                                                     !0
   11    10        DECLARE_LAMBDA_FUNCTION                              ~10     [0]
         11        BIND_LEXICAL                                                 ~10, !2
         12        BIND_LEXICAL                                                 ~10, !3
   15    13        SEND_VAL                                                     ~10
    9    14        DO_ICALL                                                     
   16    15        INIT_FCALL                                                   'var_export'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                                     
         18      > 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/MrukZ
function name:  {closure:/in/MrukZ:11}
number of ops:  17
compiled vars:  !0 = $a, !1 = $b, !2 = $priority, !3 = $fallback
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
   12     4        FETCH_DIM_IS                                         ~4      !2, !0
          5        COALESCE                                             ~5      ~4
          6        QM_ASSIGN                                            ~5      !3
          7        INIT_ARRAY                                           ~6      ~5
          8        ADD_ARRAY_ELEMENT                                    ~6      !0
   14     9        FETCH_DIM_IS                                         ~7      !2, !1
         10        COALESCE                                             ~8      ~7
         11        QM_ASSIGN                                            ~8      !3
         12        INIT_ARRAY                                           ~9      ~8
         13        ADD_ARRAY_ELEMENT                                    ~9      !1
         14        SPACESHIP                                            ~10     ~6, ~9
         15      > RETURN                                                       ~10
   15    16*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.34 ms | 1882 KiB | 16 Q