3v4l.org

run code in 300+ PHP versions simultaneously
<?php $separator = 'dot'; $number = '1.233.332,34'; $thousand_separator = ','; $decimal_separator = '.'; if ($separator != 'comma') { $thousand_separator = '.'; $decimal_separator = ','; } // Remove the thousand separator $number = str_replace($thousand_separator, '', $number); // Remove the thousand separator $number = str_replace($decimal_separator, '.', $number); echo number_format($number, 2, ',', '.');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/m38I4
function name:  (null)
number of ops:  28
compiled vars:  !0 = $separator, !1 = $number, !2 = $thousand_separator, !3 = $decimal_separator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'dot'
    4     1        ASSIGN                                                   !1, '1.233.332%2C34'
    6     2        ASSIGN                                                   !2, '%2C'
    7     3        ASSIGN                                                   !3, '.'
    9     4        IS_NOT_EQUAL                                             !0, 'comma'
          5      > JMPZ                                                     ~8, ->8
   10     6    >   ASSIGN                                                   !2, '.'
   11     7        ASSIGN                                                   !3, '%2C'
   15     8    >   INIT_FCALL                                               'str_replace'
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !1, $11
   18    14        INIT_FCALL                                               'str_replace'
         15        SEND_VAR                                                 !3
         16        SEND_VAL                                                 '.'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !1, $13
   20    20        INIT_FCALL                                               'number_format'
         21        SEND_VAR                                                 !1
         22        SEND_VAL                                                 2
         23        SEND_VAL                                                 '%2C'
         24        SEND_VAL                                                 '.'
         25        DO_ICALL                                         $15     
         26        ECHO                                                     $15
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.53 ms | 1395 KiB | 17 Q