3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.55 ms | 1388 KiB | 17 Q