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" ]; uasort( $array, function($a, $b) { sscanf($a, '%f%s', $amountA, $unitA); sscanf($b, '%f%s', $amountB, $unitB); return $amountA * UNIT_FACTOR[$unitA] <=> $amountB * UNIT_FACTOR[$unitB]; } ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nggXg
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'UNIT_FACTOR', <array>
   10     1        ASSIGN                                                   !0, <array>
   25     2        INIT_FCALL                                               'uasort'
   26     3        SEND_REF                                                 !0
   27     4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   32     5        SEND_VAL                                                 ~2
   25     6        DO_ICALL                                                 
   35     7        INIT_FCALL                                               'var_export'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > 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/nggXg
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $a, !1 = $b, !2 = $amountA, !3 = $unitA, !4 = $amountB, !5 = $unitB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        INIT_FCALL                                               'sscanf'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%25f%25s'
          5        SEND_REF                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                                 
   29     8        INIT_FCALL                                               'sscanf'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 '%25f%25s'
         11        SEND_REF                                                 !4
         12        SEND_REF                                                 !5
         13        DO_ICALL                                                 
   30    14        FETCH_CONSTANT                                   ~8      'UNIT_FACTOR'
         15        FETCH_DIM_R                                      ~9      ~8, !3
         16        MUL                                              ~10     !2, ~9
   31    17        FETCH_CONSTANT                                   ~11     'UNIT_FACTOR'
         18        FETCH_DIM_R                                      ~12     ~11, !5
         19        MUL                                              ~13     !4, ~12
         20        SPACESHIP                                        ~14     ~10, ~13
         21      > RETURN                                                   ~14
   32    22*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.52 ms | 1005 KiB | 16 Q