3v4l.org

run code in 300+ PHP versions simultaneously
<?php $aShips = ['0_204' => 1, '0_209' => 1.5,'0_205' => 2, '0_206' => 3, '0_207' => 4]; $order = ["0_206", "0_205", "0_204", "0_207"]; $lookup = array_flip(array_reverse($order)); uksort($aShips, function($a, $b) use ($lookup) { return ($lookup[$b] ?? -1) <=> ($lookup[$a] ?? -1); }); var_export($aShips);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gHWoT
function name:  (null)
number of ops:  19
compiled vars:  !0 = $aShips, !1 = $order, !2 = $lookup
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        INIT_FCALL                                               'array_reverse'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $5      
          6        SEND_VAR                                                 $5
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
    7     9        INIT_FCALL                                               'uksort'
         10        SEND_REF                                                 !0
         11        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
         12        BIND_LEXICAL                                             ~8, !2
    9    13        SEND_VAL                                                 ~8
    7    14        DO_ICALL                                                 
   11    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/gHWoT
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $a, !1 = $b, !2 = $lookup
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, !1
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      -1
          6        FETCH_DIM_IS                                     ~5      !2, !0
          7        COALESCE                                         ~6      ~5
          8        QM_ASSIGN                                        ~6      -1
          9        SPACESHIP                                        ~7      ~4, ~6
         10      > RETURN                                                   ~7
    9    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.06 ms | 1004 KiB | 17 Q