3v4l.org

run code in 300+ PHP versions simultaneously
<?php $callback = function ($matches) { $string = $matches[0]; $string = str_replace(' ', '', $string); // remove unwanted whitespace $string = str_replace('(,', '(', $string); // remove unwanted comma $string = str_replace(',)', ')', $string); // remove unwanted comma $string = str_replace(',,', ',', $string); return $string; }; $string = '(`anurag`, 1,2), (1,2,3, `dm0c60544`),(2 ,3 ,3) '; $pattern = '#[0-9,()]#'; // our regex pattern $string = preg_replace_callback($pattern, $callback, $string); //replace backticked text and the following comma echo $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZ3nK
function name:  (null)
number of ops:  12
compiled vars:  !0 = $callback, !1 = $string, !2 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLZ3nK%3A4%240'
          1        ASSIGN                                                   !0, ~3
   14     2        ASSIGN                                                   !1, '%28%60anurag%60%2C+1%2C2%29%2C+%281%2C2%2C3%2C+%60dm0c60544%60%29%2C%282+%2C3++%2C3%29+'
   16     3        ASSIGN                                                   !2, '%23%5B0-9%2C%28%29%5D%23'
   18     4        INIT_FCALL                                               'preg_replace_callback'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
   20    10        ECHO                                                     !1
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLZ3nK%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZ3nK
function name:  {closure}
number of ops:  29
compiled vars:  !0 = $matches, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_DIM_R                                      ~2      !0, 0
          2        ASSIGN                                                   !1, ~2
    6     3        INIT_FCALL                                               'str_replace'
          4        SEND_VAL                                                 '+'
          5        SEND_VAL                                                 ''
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
    7     9        INIT_FCALL                                               'str_replace'
         10        SEND_VAL                                                 '%28%2C'
         11        SEND_VAL                                                 '%28'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !1, $6
    8    15        INIT_FCALL                                               'str_replace'
         16        SEND_VAL                                                 '%2C%29'
         17        SEND_VAL                                                 '%29'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $8      
         20        ASSIGN                                                   !1, $8
    9    21        INIT_FCALL                                               'str_replace'
         22        SEND_VAL                                                 '%2C%2C'
         23        SEND_VAL                                                 '%2C'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $10     
         26        ASSIGN                                                   !1, $10
   10    27      > RETURN                                                   !1
   11    28*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLZ3nK%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.73 ms | 1392 KiB | 17 Q