3v4l.org

run code in 300+ PHP versions simultaneously
<?php $unsorted = [ "3470U11", "3470E11", "3470S13", "3470G11", "3470S12", "3470S11", "3470E12", "3470U12", "3470G13", "3470G12", "3470E13", "3470U13" ]; $sortBy = ['G', 'D', 'S', 'U', 'E', 'T', 'A', 'L']; $priority = array_flip($sortBy); usort( $unsorted, fn($a, $b) => ($priority[substr($a, -3, 1)] <=> $priority[substr($b, -3, 1)]) ?: $a <=> $b ); var_export ($unsorted);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DHvQS
function name:  (null)
number of ops:  16
compiled vars:  !0 = $unsorted, !1 = $sortBy, !2 = $priority
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   21     6        INIT_FCALL                                               'usort'
   22     7        SEND_REF                                                 !0
   23     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDHvQS%3A23%240'
          9        BIND_LEXICAL                                             ~7, !2
   26    10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   28    12        INIT_FCALL                                               'var_export'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FDHvQS%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DHvQS
function name:  {closure}
number of ops:  21
compiled vars:  !0 = $a, !1 = $b, !2 = $priority
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   24     3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 -3
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $3      
          8        FETCH_DIM_R                                      ~4      !2, $3
          9        INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !1
         11        SEND_VAL                                                 -3
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $5      
         14        FETCH_DIM_R                                      ~6      !2, $5
         15        SPACESHIP                                        ~7      ~4, ~6
         16        JMP_SET                                          ~8      ~7, ->19
   25    17        SPACESHIP                                        ~9      !0, !1
         18        QM_ASSIGN                                        ~8      ~9
         19      > RETURN                                                   ~8
   26    20*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDHvQS%3A23%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.16 ms | 1396 KiB | 21 Q