3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sizes = array("L", "XXXL", "INVALID", "M", "S"); function compare($a, $b) { $sizeincrement = array("XS", "S", "M", "L", "XL", "XXL", "XXXL"); if(!in_array($a, $sizeincrement)) return 1; if(!in_array($b, $sizeincrement)) return -1; return array_search($a, $sizeincrement) > array_search($b, $sizeincrement); } usort($sizes, "compare"); print_r($sizes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YpN3d
function name:  (null)
number of ops:  9
compiled vars:  !0 = $sizes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'compare'
          4        DO_ICALL                                                 
   13     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YpN3d
function name:  compare
number of ops:  28
compiled vars:  !0 = $a, !1 = $b, !2 = $sizeincrement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    6     3        INIT_FCALL                                               'in_array'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $4      
          7        BOOL_NOT                                         ~5      $4
          8      > JMPZ                                                     ~5, ->10
          9    > > RETURN                                                   1
    7    10    >   INIT_FCALL                                               'in_array'
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $6      
         14        BOOL_NOT                                         ~7      $6
         15      > JMPZ                                                     ~7, ->17
         16    > > RETURN                                                   -1
    8    17    >   INIT_FCALL                                               'array_search'
         18        SEND_VAR                                                 !0
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $8      
         21        INIT_FCALL                                               'array_search'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $9      
         25        IS_SMALLER                                       ~10     $9, $8
         26      > RETURN                                                   ~10
    9    27*     > RETURN                                                   null

End of function compare

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.39 ms | 1392 KiB | 21 Q