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 floor(($n/1000000000000)).'T'; else if($n>1000000000) return floor(($n/1000000000)).'G'; else if($n>1000000) return floor(($n/1000000)).'M'; else if($n>1000) return floor(($n/1000)).'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/S8gK4
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 = 23
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S8gK4
function name:  count_number
number of ops:  54
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, ->23
         16    >   INIT_FCALL                                               'floor'
         17        DIV                                              ~7      !0, 1000000000000
         18        SEND_VAL                                                 ~7
         19        DO_ICALL                                         $8      
         20        CONCAT                                           ~9      $8, 'T'
         21      > RETURN                                                   ~9
         22*       JMP                                                      ->49
   11    23    >   IS_SMALLER                                               1000000000, !0
         24      > JMPZ                                                     ~10, ->32
         25    >   INIT_FCALL                                               'floor'
         26        DIV                                              ~11     !0, 1000000000
         27        SEND_VAL                                                 ~11
         28        DO_ICALL                                         $12     
         29        CONCAT                                           ~13     $12, 'G'
         30      > RETURN                                                   ~13
         31*       JMP                                                      ->49
   12    32    >   IS_SMALLER                                               1000000, !0
         33      > JMPZ                                                     ~14, ->41
         34    >   INIT_FCALL                                               'floor'
         35        DIV                                              ~15     !0, 1000000
         36        SEND_VAL                                                 ~15
         37        DO_ICALL                                         $16     
         38        CONCAT                                           ~17     $16, 'M'
         39      > RETURN                                                   ~17
         40*       JMP                                                      ->49
   13    41    >   IS_SMALLER                                               1000, !0
         42      > JMPZ                                                     ~18, ->49
         43    >   INIT_FCALL                                               'floor'
         44        DIV                                              ~19     !0, 1000
         45        SEND_VAL                                                 ~19
         46        DO_ICALL                                         $20     
         47        CONCAT                                           ~21     $20, 'K'
         48      > RETURN                                                   ~21
   15    49    >   INIT_FCALL                                               'number_format'
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                         $22     
         52      > RETURN                                                   $22
   16    53*     > RETURN                                                   null

End of function count_number

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.31 ms | 1403 KiB | 22 Q