3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fNumString(string $numberString, string $decimalPoint = '.', string $thousandsSeparator = ','): string { [$integerPart, $decimalPart] = array_pad(explode('.', $numberString, 2), 2, null); $integerPart = strrev(preg_replace('/\d{3}(?=\d)/', '\0' . $thousandsSeparator, strrev($integerPart))); return $integerPart . ($decimalPart ? $decimalPoint . $decimalPart : ''); } echo fNumString('1000.382'), PHP_EOL; echo fNumString('99.01'), PHP_EOL; echo fNumString('1900000'), PHP_EOL; echo fNumString('19000000000000000000123.12399999999198');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m3jUC
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'fnumstring'
          1        SEND_VAL                                                 '1000.382'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4        ECHO                                                     '%0A'
   10     5        INIT_FCALL                                               'fnumstring'
          6        SEND_VAL                                                 '99.01'
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9        ECHO                                                     '%0A'
   11    10        INIT_FCALL                                               'fnumstring'
         11        SEND_VAL                                                 '1900000'
         12        DO_FCALL                                      0  $2      
         13        ECHO                                                     $2
         14        ECHO                                                     '%0A'
   12    15        INIT_FCALL                                               'fnumstring'
         16        SEND_VAL                                                 '19000000000000000000123.12399999999198'
         17        DO_FCALL                                      0  $3      
         18        ECHO                                                     $3
         19      > RETURN                                                   1

Function fnumstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m3jUC
function name:  fNumString
number of ops:  41
compiled vars:  !0 = $numberString, !1 = $decimalPoint, !2 = $thousandsSeparator, !3 = $integerPart, !4 = $decimalPart
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '.'
          2        RECV_INIT                                        !2      '%2C'
    4     3        INIT_FCALL                                               'array_pad'
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '.'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        SEND_VAL                                                 2
         11        SEND_VAL                                                 null
         12        DO_ICALL                                         $6      
         13        FETCH_LIST_R                                     $7      $6, 0
         14        ASSIGN                                                   !3, $7
         15        FETCH_LIST_R                                     $9      $6, 1
         16        ASSIGN                                                   !4, $9
         17        FREE                                                     $6
    5    18        INIT_FCALL                                               'strrev'
         19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%2F%5Cd%7B3%7D%28%3F%3D%5Cd%29%2F'
         21        CONCAT                                           ~11     '%5C0', !2
         22        SEND_VAL                                                 ~11
         23        INIT_FCALL                                               'strrev'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $12     
         26        SEND_VAR                                                 $12
         27        DO_ICALL                                         $13     
         28        SEND_VAR                                                 $13
         29        DO_ICALL                                         $14     
         30        ASSIGN                                                   !3, $14
    7    31      > JMPZ                                                     !4, ->35
         32    >   CONCAT                                           ~16     !1, !4
         33        QM_ASSIGN                                        ~17     ~16
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~17     ''
         36    >   CONCAT                                           ~18     !3, ~17
         37        VERIFY_RETURN_TYPE                                       ~18
         38      > RETURN                                                   ~18
    8    39*       VERIFY_RETURN_TYPE                                       
         40*     > RETURN                                                   null

End of function fnumstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
268.36 ms | 1021 KiB | 21 Q