3v4l.org

run code in 500+ 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:  27
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        FRAMELESS_ICALL_3                preg_replace        ~6      !0, !1
          5        OP_DATA                                                      !2
          6        SEND_VAL                                                     ~6
          7        DO_ICALL                                                     
   10     8        ASSIGN                                                       !2, 123456789
   12     9        INIT_FCALL                                                   'var_dump'
         10        FRAMELESS_ICALL_3                preg_replace        ~9      !0, !1
         11        OP_DATA                                                      !2
         12        SEND_VAL                                                     ~9
         13        DO_ICALL                                                     
   14    14        ASSIGN                                                       !2, 123
   15    15        INIT_FCALL                                                   'var_dump'
         16        FRAMELESS_ICALL_3                preg_replace        ~12     !0, !1
         17        OP_DATA                                                      !2
         18        SEND_VAL                                                     ~12
         19        DO_ICALL                                                     
   17    20        ASSIGN                                                       !2, 1234567890
   19    21        INIT_FCALL                                                   'var_dump'
         22        FRAMELESS_ICALL_3                preg_replace        ~15     !0, !1
         23        OP_DATA                                                      !2
         24        SEND_VAL                                                     ~15
         25        DO_ICALL                                                     
         26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
189.23 ms | 1654 KiB | 14 Q