3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = '/some-folders/../pattern,also-replacement-area/parameter-one'; echo preg_replace('~(?:^.*?/pattern,)?(?!^)[^/-]*+\K-~A', '~', $str), PHP_EOL, preg_replace_callback('~/pattern,[^/]*~', fn($m) => strtr($m[0], '-', '~'), $str), // other way (more simple pattern) PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2uEL0
function name:  (null)
number of ops:  14
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2Fsome-folders%2F..%2Fpattern%2Calso-replacement-area%2Fparameter-one'
    5     1        FRAMELESS_ICALL_3                preg_replace        ~2      '%7E%28%3F%3A%5E.%2A%3F%2Fpattern%2C%29%3F%28%3F%21%5E%29%5B%5E%2F-%5D%2A%2B%5CK-%7EA', '%7E'
          2        OP_DATA                                                      !0
          3        ECHO                                                         ~2
    6     4        ECHO                                                         '%0A'
    7     5        INIT_FCALL                                                   'preg_replace_callback'
          6        SEND_VAL                                                     '%7E%2Fpattern%2C%5B%5E%2F%5D%2A%7E'
          7        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          8        SEND_VAL                                                     ~3
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                             $4      
         11        ECHO                                                         $4
    8    12        ECHO                                                         '%0A'
    9    13      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2uEL0
function name:  {closure:/in/2uEL0:7}
number of ops:  6
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~1      !0, 0
          2        FRAMELESS_ICALL_3                strtr               ~2      ~1, '-'
          3        OP_DATA                                                      '%7E'
          4      > RETURN                                                       ~2
          5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
135.45 ms | 1961 KiB | 14 Q