3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert($i){ $rules = array("KB"=>1000, "MB"=>1000000, "GB"=>1000000000,"TB"=>1000000000000); $reversedRules= array_reverse($rules); foreach($reversedRules as $k=>$r){ if(($output = $i/$r) >= 1){ return round($output).$k; } } return $i."B"; } echo convert(21312312312312321); echo convert(1000); echo convert(1232); echo convert(9999999); echo convert(12); echo convert(231671851); echo convert(321784535432);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nY4V7
function name:  (null)
number of ops:  29
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'convert'
          1        SEND_VAL                                                 21312312312312321
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   20     4        INIT_FCALL                                               'convert'
          5        SEND_VAL                                                 1000
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   21     8        INIT_FCALL                                               'convert'
          9        SEND_VAL                                                 1232
         10        DO_FCALL                                      0  $2      
         11        ECHO                                                     $2
   22    12        INIT_FCALL                                               'convert'
         13        SEND_VAL                                                 9999999
         14        DO_FCALL                                      0  $3      
         15        ECHO                                                     $3
   23    16        INIT_FCALL                                               'convert'
         17        SEND_VAL                                                 12
         18        DO_FCALL                                      0  $4      
         19        ECHO                                                     $4
   24    20        INIT_FCALL                                               'convert'
         21        SEND_VAL                                                 231671851
         22        DO_FCALL                                      0  $5      
         23        ECHO                                                     $5
   25    24        INIT_FCALL                                               'convert'
         25        SEND_VAL                                                 321784535432
         26        DO_FCALL                                      0  $6      
         27        ECHO                                                     $6
         28      > RETURN                                                   1

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/nY4V7
function name:  convert
number of ops:  24
compiled vars:  !0 = $i, !1 = $rules, !2 = $reversedRules, !3 = $r, !4 = $k, !5 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_reverse'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
    7     6      > FE_RESET_R                                       $9      !2, ->20
          7    > > FE_FETCH_R                                       ~10     $9, !3, ->20
          8    >   ASSIGN                                                   !4, ~10
    8     9        DIV                                              ~12     !0, !3
         10        ASSIGN                                           ~13     !5, ~12
         11        IS_SMALLER_OR_EQUAL                                      1, ~13
         12      > JMPZ                                                     ~14, ->19
    9    13    >   INIT_FCALL                                               'round'
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                         $15     
         16        CONCAT                                           ~16     $15, !4
         17        FE_FREE                                                  $9
         18      > RETURN                                                   ~16
    7    19    > > JMP                                                      ->7
         20    >   FE_FREE                                                  $9
   14    21        CONCAT                                           ~17     !0, 'B'
         22      > RETURN                                                   ~17
   17    23*     > RETURN                                                   null

End of function convert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.73 ms | 1010 KiB | 22 Q