3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/(\d{3}(?!$))(\d{3}$)?/'; $replacement = '$1,$2'; $num = 1234; var_dump(preg_replace($pattern, $replacement, $num)); //123,4 $num = 123456789; var_dump(preg_replace($pattern, $replacement, $num)); //123,456,789 $num = 123; var_dump(preg_replace($pattern, $replacement, $num)); //123 $num = 1234567890; var_dump(preg_replace($pattern, $replacement, $num)); //123,456,789,0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPVus
function name:  (null)
number of ops:  39
compiled vars:  !0 = $pattern, !1 = $replacement, !2 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28%5Cd%7B3%7D%28%3F%21%24%29%29%28%5Cd%7B3%7D%24%29%3F%2F'
    4     1        ASSIGN                                                   !1, '%241%2C%242'
    6     2        ASSIGN                                                   !2, 1234
    8     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   10    11        ASSIGN                                                   !2, 123456789
   12    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   14    20        ASSIGN                                                   !2, 123
   15    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'preg_replace'
         23        SEND_VAR                                                 !0
         24        SEND_VAR                                                 !1
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $12     
         27        SEND_VAR                                                 $12
         28        DO_ICALL                                                 
   17    29        ASSIGN                                                   !2, 1234567890
   19    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'preg_replace'
         32        SEND_VAR                                                 !0
         33        SEND_VAR                                                 !1
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                         $15     
         36        SEND_VAR                                                 $15
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.04 ms | 1438 KiB | 15 Q