3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ "GL001_M", "GL001_XL", "GL001_S", "GL001_L", "GL002_M", "GL002_XS", "GL002_S", "GL002_L" ]; define('SIZES', array_flip(['XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL'])); array_multisort( ...array_merge( array_map( null, ...array_map( fn($v) => (fn($id, $size) => [$id, SIZES[$size]])(...explode('_', $v, 2)), $array ) ), [&$array] ) ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v9Vvk
function name:  (null)
number of ops:  33
compiled vars:  !0 = $array, !1 = $id, !2 = $size
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   14     1        INIT_FCALL                                                   'define'
          2        SEND_VAL                                                     'SIZES'
          3        INIT_FCALL                                                   'array_flip'
          4        SEND_VAL                                                     <array>
          5        DO_ICALL                                             $4      
          6        SEND_VAR                                                     $4
          7        DO_ICALL                                                     
   16     8        INIT_FCALL                                                   'array_multisort'
   17     9        INIT_FCALL                                                   'array_merge'
   18    10        INIT_FCALL                                                   'array_map'
   19    11        SEND_VAL                                                     null
   20    12        INIT_FCALL                                                   'array_map'
   21    13        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
         14        BIND_LEXICAL                                                 ~6, !1
         15        BIND_LEXICAL                                                 ~6, !2
   22    16        SEND_VAL                                                     ~6
   23    17        SEND_VAR                                                     !0
   20    18        DO_ICALL                                             $7      
   23    19        SEND_UNPACK                                                  $7
         20        CHECK_UNDEF_ARGS                                             
   18    21        DO_ICALL                                             $8      
   23    22        SEND_VAR                                                     $8
   26    23        INIT_ARRAY                                           ~9      !0
         24        SEND_VAL                                                     ~9
   17    25        DO_ICALL                                             $10     
   26    26        SEND_UNPACK                                                  $10
         27        CHECK_UNDEF_ARGS                                             
   16    28        DO_ICALL                                                     
   29    29        INIT_FCALL                                                   'var_export'
         30        SEND_VAR                                                     !0
         31        DO_ICALL                                                     
         32      > 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/v9Vvk
function name:  {closure:/in/v9Vvk:21}
number of ops:  15
compiled vars:  !0 = $v, !1 = $id, !2 = $size
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
   22     3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          4        INIT_DYNAMIC_CALL                                            ~3
          5        INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '_'
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     2
          9        DO_ICALL                                             $4      
         10        SEND_UNPACK                                                  $4
         11        CHECK_UNDEF_ARGS                                             
         12        DO_FCALL                                          1  $5      
         13      > RETURN                                                       $5
         14*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v9Vvk
function name:  {closure:{closure:/in/v9Vvk:21}:22}
number of ops:  8
compiled vars:  !0 = $id, !1 = $size
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
          0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        INIT_ARRAY                                           ~2      !0
          3        FETCH_CONSTANT                                       ~3      'SIZES'
          4        FETCH_DIM_R                                          ~4      ~3, !1
          5        ADD_ARRAY_ELEMENT                                    ~2      ~4
          6      > RETURN                                                       ~2
          7*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.42 ms | 1743 KiB | 20 Q