3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array( 1234, 1234.05, 1234.005, 1234.5, 1234.55, 1234.505, 1234.555, 3, 3.05, 3.5, 3.55, 3.555, 3.5555, 5.49, 5.255, 5.252, 5.249, 5.244, 2.245, ); function format_to_komma_ruggit($number, $decimals) { $number = round($number, $decimals); $number = number_format($number, strlen(substr(strrchr($number, "."), 1)), ',', '.'); return $number; } foreach ($numbers as $number) { echo $number . ' => ' . format_to_komma_ruggit($number, 2); echo "\r\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/KX6c1
function name:  (null)
number of ops:  14
compiled vars:  !0 = $numbers, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   32     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   33     3    >   CONCAT                                           ~4      !1, '+%3D%3E+'
          4        INIT_FCALL                                               'format_to_komma_ruggit'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 2
          7        DO_FCALL                                      0  $5      
          8        CONCAT                                           ~6      ~4, $5
          9        ECHO                                                     ~6
   34    10        ECHO                                                     '%0D%0A'
   32    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   35    13      > RETURN                                                   1

Function format_to_komma_ruggit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KX6c1
function name:  format_to_komma_ruggit
number of ops:  25
compiled vars:  !0 = $number, !1 = $decimals
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_FCALL                                               'round'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   27     7        INIT_FCALL                                               'number_format'
          8        SEND_VAR                                                 !0
          9        INIT_FCALL                                               'substr'
         10        INIT_FCALL                                               'strrchr'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '.'
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $5      
         17        STRLEN                                           ~6      $5
         18        SEND_VAL                                                 ~6
         19        SEND_VAL                                                 '%2C'
         20        SEND_VAL                                                 '.'
         21        DO_ICALL                                         $7      
         22        ASSIGN                                                   !0, $7
   29    23      > RETURN                                                   !0
   30    24*     > RETURN                                                   null

End of function format_to_komma_ruggit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.26 ms | 1407 KiB | 22 Q