3v4l.org

run code in 300+ PHP versions simultaneously
<?php const UNIT_FACTOR = [ 'B' => 1, 'KB' => 1024, 'MB' => 1048576, 'GB' => 1073741824, ]; $array = [ 0 => "100 MB", 4 => "10 MB", 8 => "1GB", 12 => "20 MB", 16 => "250 MB", 20 => "2GB", 24 => "4 MB", 28 => "500 MB", 32 => "50 MB", 36 => "5GB", 40 => "8GB", 44 => "0 MB" ]; $bytes = []; foreach ($array as $string) { sscanf($string, '%f%s', $amount, $unit); $bytes[] = $amount * UNIT_FACTOR[$unit]; } array_multisort($bytes, $array); var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/nti2H
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $bytes, !2 = $string, !3 = $amount, !4 = $unit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'UNIT_FACTOR', <array>
   10     1        ASSIGN                                                   !0, <array>
   25     2        ASSIGN                                                   !1, <array>
   26     3      > FE_RESET_R                                       $7      !0, ->17
          4    > > FE_FETCH_R                                               $7, !2, ->17
   27     5    >   INIT_FCALL                                               'sscanf'
          6        SEND_VAR                                                 !2
          7        SEND_VAL                                                 '%25f%25s'
          8        SEND_REF                                                 !3
          9        SEND_REF                                                 !4
         10        DO_ICALL                                                 
   28    11        FETCH_CONSTANT                                   ~10     'UNIT_FACTOR'
         12        FETCH_DIM_R                                      ~11     ~10, !4
         13        MUL                                              ~12     !3, ~11
         14        ASSIGN_DIM                                               !1
         15        OP_DATA                                                  ~12
   26    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $7
   31    18        INIT_FCALL                                               'array_multisort'
         19        SEND_REF                                                 !1
         20        SEND_REF                                                 !0
         21        DO_ICALL                                                 
   32    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.75 ms | 1004 KiB | 16 Q