3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert($n) { $n = (0 + str_replace(",", "", $n)); if (!is_numeric($n)) return false; if ($n > 1000000000000) return round(($n / 1000000000000) , 1) . 'T'; else if ($n > 1000000000) return round(($n / 1000000000) , 1) . 'B'; else if ($n > 1000000) return round(($n / 1000000) , 1) . 'M'; else if ($n > 1000) return round(($n / 1000) , 1) . 'K'; return number_format($n); } $n = convert('35,578,926'); echo $n; // 35.5M
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qdl5V
function name:  (null)
number of ops:  6
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'convert'
          1        SEND_VAL                                                 '35%2C578%2C926'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   15     4        ECHO                                                     !0
          5      > RETURN                                                   1

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 44
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qdl5V
function name:  convert
number of ops:  58
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%2C'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ADD                                              ~2      0, $1
          7        ASSIGN                                                   !0, ~2
    6     8        INIT_FCALL                                               'is_numeric'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        BOOL_NOT                                         ~5      $4
         12      > JMPZ                                                     ~5, ->14
         13    > > RETURN                                                   <false>
    7    14    >   IS_SMALLER                                               1000000000000, !0
         15      > JMPZ                                                     ~6, ->24
         16    >   INIT_FCALL                                               'round'
         17        DIV                                              ~7      !0, 1000000000000
         18        SEND_VAL                                                 ~7
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $8      
         21        CONCAT                                           ~9      $8, 'T'
         22      > RETURN                                                   ~9
         23*       JMP                                                      ->53
    8    24    >   IS_SMALLER                                               1000000000, !0
         25      > JMPZ                                                     ~10, ->34
         26    >   INIT_FCALL                                               'round'
         27        DIV                                              ~11     !0, 1000000000
         28        SEND_VAL                                                 ~11
         29        SEND_VAL                                                 1
         30        DO_ICALL                                         $12     
         31        CONCAT                                           ~13     $12, 'B'
         32      > RETURN                                                   ~13
         33*       JMP                                                      ->53
    9    34    >   IS_SMALLER                                               1000000, !0
         35      > JMPZ                                                     ~14, ->44
         36    >   INIT_FCALL                                               'round'
         37        DIV                                              ~15     !0, 1000000
         38        SEND_VAL                                                 ~15
         39        SEND_VAL                                                 1
         40        DO_ICALL                                         $16     
         41        CONCAT                                           ~17     $16, 'M'
         42      > RETURN                                                   ~17
         43*       JMP                                                      ->53
   10    44    >   IS_SMALLER                                               1000, !0
         45      > JMPZ                                                     ~18, ->53
         46    >   INIT_FCALL                                               'round'
         47        DIV                                              ~19     !0, 1000
         48        SEND_VAL                                                 ~19
         49        SEND_VAL                                                 1
         50        DO_ICALL                                         $20     
         51        CONCAT                                           ~21     $20, 'K'
         52      > RETURN                                                   ~21
   11    53    >   INIT_FCALL                                               'number_format'
         54        SEND_VAR                                                 !0
         55        DO_ICALL                                         $22     
         56      > RETURN                                                   $22
   12    57*     > RETURN                                                   null

End of function convert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
290.53 ms | 1021 KiB | 18 Q