3v4l.org

run code in 300+ PHP versions simultaneously
<?php function intWithStyle($n) { if ($n < 1000) return $n; $suffix = ['','k','M','G','T','P','E','Z','Y']; $zeros = strlen($n)/3; $power = is_float($zeros) ? (int) $zeros : $zeros - 1; return round($n/(1000**$power),3).$suffix[$power]; } ini_set('precision', 17); var_dump(intWithStyle(1001));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CC0b2
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'precision'
          2        SEND_VAL                                                 17
          3        DO_ICALL                                                 
   17     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'intwithstyle'
          6        SEND_VAL                                                 1001
          7        DO_FCALL                                      0  $1      
          8        SEND_VAR                                                 $1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function intwithstyle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CC0b2
function name:  intWithStyle
number of ops:  26
compiled vars:  !0 = $n, !1 = $suffix, !2 = $zeros, !3 = $power
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        IS_SMALLER                                               !0, 1000
          2      > JMPZ                                                     ~4, ->4
          3    > > RETURN                                                   !0
    7     4    >   ASSIGN                                                   !1, <array>
    8     5        STRLEN                                           ~6      !0
          6        DIV                                              ~7      ~6, 3
          7        ASSIGN                                                   !2, ~7
   10     8        TYPE_CHECK                                   32          !2
          9      > JMPZ                                                     ~9, ->13
         10    >   CAST                                          4  ~10     !2
         11        QM_ASSIGN                                        ~11     ~10
         12      > JMP                                                      ->15
         13    >   SUB                                              ~12     !2, 1
         14        QM_ASSIGN                                        ~11     ~12
         15    >   ASSIGN                                                   !3, ~11
   11    16        INIT_FCALL                                               'round'
         17        POW                                              ~14     1000, !3
         18        DIV                                              ~15     !0, ~14
         19        SEND_VAL                                                 ~15
         20        SEND_VAL                                                 3
         21        DO_ICALL                                         $16     
         22        FETCH_DIM_R                                      ~17     !1, !3
         23        CONCAT                                           ~18     $16, ~17
         24      > RETURN                                                   ~18
   12    25*     > RETURN                                                   null

End of function intwithstyle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.28 ms | 1436 KiB | 17 Q