3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_number($n) { // first strip any formatting; $n = (0+str_replace(",","",$n)); // is this a number? if(!is_numeric($n)) return false; // now filter it; if($n>1000000000000) return round(($n/1000000000000),1).'T'; else if($n>1000000000) return round(($n/1000000000),1).'G'; else if($n>1000000) return round(($n/1000000),1).'M'; else if($n>1000) return round(($n/1000),1).'K'; return number_format($n); } echo count_number("2,454");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d4NJc
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'count_number'
          1        SEND_VAL                                                 '2%2C454'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function count_number:
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/d4NJc
function name:  count_number
number of ops:  58
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     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
    7     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>
   10    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
   11    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, 'G'
         32      > RETURN                                                   ~13
         33*       JMP                                                      ->53
   12    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
   13    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
   15    53    >   INIT_FCALL                                               'number_format'
         54        SEND_VAR                                                 !0
         55        DO_ICALL                                         $22     
         56      > RETURN                                                   $22
   16    57*     > RETURN                                                   null

End of function count_number

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148 ms | 1402 KiB | 22 Q