3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getFormattedNumber($n) { if($n<1000) return $n; $precision = 0; if($n < 1000000) { $m = $n/1000; if(is_float($m) AND $m<99) $precision = 1; var_dump($precision); return round($m, $precision, PHP_ROUND_HALF_DOWN).'K'; } $m = $n/1000000; if(is_float($m) AND $m<99) $precision = 1; var_dump($precision); return round($m, $precision, PHP_ROUND_HALF_DOWN).'M'; } echo getFormattedNumber(925926);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AL4I5
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'getformattednumber'
          1        SEND_VAL                                                 925926
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function getformattednumber:
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 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 13
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 31
filename:       /in/AL4I5
function name:  getFormattedNumber
number of ops:  44
compiled vars:  !0 = $n, !1 = $precision, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        IS_SMALLER                                               !0, 1000
          2      > JMPZ                                                     ~3, ->4
          3    > > RETURN                                                   !0
    6     4    >   ASSIGN                                                   !1, 0
    8     5        IS_SMALLER                                               !0, 1000000
          6      > JMPZ                                                     ~5, ->25
   10     7    >   DIV                                              ~6      !0, 1000
          8        ASSIGN                                                   !2, ~6
   11     9        TYPE_CHECK                                   32  ~8      !2
         10      > JMPZ_EX                                          ~8      ~8, ->13
         11    >   IS_SMALLER                                       ~9      !2, 99
         12        BOOL                                             ~8      ~9
         13    > > JMPZ                                                     ~8, ->15
         14    >   ASSIGN                                                   !1, 1
   12    15    >   INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
   13    18        INIT_FCALL                                               'round'
         19        SEND_VAR                                                 !2
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 2
         22        DO_ICALL                                         $12     
         23        CONCAT                                           ~13     $12, 'K'
         24      > RETURN                                                   ~13
   16    25    >   DIV                                              ~14     !0, 1000000
         26        ASSIGN                                                   !2, ~14
   17    27        TYPE_CHECK                                   32  ~16     !2
         28      > JMPZ_EX                                          ~16     ~16, ->31
         29    >   IS_SMALLER                                       ~17     !2, 99
         30        BOOL                                             ~16     ~17
         31    > > JMPZ                                                     ~16, ->33
         32    >   ASSIGN                                                   !1, 1
   18    33    >   INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
   19    36        INIT_FCALL                                               'round'
         37        SEND_VAR                                                 !2
         38        SEND_VAR                                                 !1
         39        SEND_VAL                                                 2
         40        DO_ICALL                                         $20     
         41        CONCAT                                           ~21     $20, 'M'
         42      > RETURN                                                   ~21
   20    43*     > RETURN                                                   null

End of function getformattednumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.34 ms | 1403 KiB | 18 Q