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'])); $ids = []; $sizes = []; foreach ($array as $v) { [$ids[], $size] = explode('_', $v, 2); $sizes[] = SIZES[$size]; } array_multisort($ids, $sizes, $array); var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 28
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/topap
function name:  (null)
number of ops:  38
compiled vars:  !0 = $array, !1 = $ids, !2 = $sizes, !3 = $v, !4 = $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                                             $6      
          6        SEND_VAR                                                     $6
          7        DO_ICALL                                                     
   16     8        ASSIGN                                                       !1, <array>
   17     9        ASSIGN                                                       !2, <array>
   18    10      > FE_RESET_R                                           $10     !0, ->28
         11    > > FE_FETCH_R                                                   $10, !3, ->28
   19    12    >   INIT_FCALL                                                   'explode'
         13        SEND_VAL                                                     '_'
         14        SEND_VAR                                                     !3
         15        SEND_VAL                                                     2
         16        DO_ICALL                                             $11     
         17        FETCH_LIST_R                                         $12     $11, 0
         18        ASSIGN_DIM                                                   !1
         19        OP_DATA                                                      $12
         20        FETCH_LIST_R                                         $14     $11, 1
         21        ASSIGN                                                       !4, $14
         22        FREE                                                         $11
   20    23        FETCH_CONSTANT                                       ~17     'SIZES'
         24        FETCH_DIM_R                                          ~18     ~17, !4
         25        ASSIGN_DIM                                                   !2
         26        OP_DATA                                                      ~18
   18    27      > JMP                                                          ->11
         28    >   FE_FREE                                                      $10
   22    29        INIT_FCALL                                                   'array_multisort'
         30        SEND_REF                                                     !1
         31        SEND_REF                                                     !2
         32        SEND_REF                                                     !0
         33        DO_ICALL                                                     
   23    34        INIT_FCALL                                                   'var_export'
         35        SEND_VAR                                                     !0
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
195.06 ms | 1737 KiB | 18 Q