3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array( 1234, 1234.0, 1234.05, 1234.005, 1234.5, 1234.50, 1234.55, 1234.505, 1234.555, 1234.5000, 1234.5500, 1234.5550, 1234.5555, 3, 3.0, 3.05, 3.5, 3.50, 3.55, 3.550, 3.555, 3.5550, 3.5555, 5.49, 5.255, 5.249, 5.244, 2.245, ); function format_to_komma_ruggit($number) { $number = round($number); $number = number_format($number, strlen(substr(strrchr($number, "."), 1)), ',', '.'); return $number; } foreach ($numbers as $number) { echo (float)$number . ' => ' . format_to_komma_ruggit($number); echo PHP_EOL; }
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/mDjWB
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>
   42     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   43     3    >   CAST                                          5  ~4      !1
          4        CONCAT                                           ~5      ~4, '+%3D%3E+'
          5        INIT_FCALL                                               'format_to_komma_ruggit'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        CONCAT                                           ~7      ~5, $6
          9        ECHO                                                     ~7
   44    10        ECHO                                                     '%0A'
   42    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   45    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/mDjWB
function name:  format_to_komma_ruggit
number of ops:  23
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'round'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   37     5        INIT_FCALL                                               'number_format'
          6        SEND_VAR                                                 !0
          7        INIT_FCALL                                               'substr'
          8        INIT_FCALL                                               'strrchr'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 '.'
         11        DO_ICALL                                         $3      
         12        SEND_VAR                                                 $3
         13        SEND_VAL                                                 1
         14        DO_ICALL                                         $4      
         15        STRLEN                                           ~5      $4
         16        SEND_VAL                                                 ~5
         17        SEND_VAL                                                 '%2C'
         18        SEND_VAL                                                 '.'
         19        DO_ICALL                                         $6      
         20        ASSIGN                                                   !0, $6
   39    21      > RETURN                                                   !0
   40    22*     > RETURN                                                   null

End of function format_to_komma_ruggit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.05 ms | 1403 KiB | 22 Q