3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string='bla bla xxx bla *xxx bla bla **xxx bla bla ***xxx bla bla ****xxx'; $search='xxx'; $char='*'; $string = preg_replace_callback( '/(' . preg_quote($char) . '*)(' . $search . ')/', function($matches) { global $char; if(strlen($matches[1]) % 2 === 0) { return $matches[1] . $char . $matches[2]; } else { return $matches[0]; } }, $string ); print $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZKOF
function name:  (null)
number of ops:  19
compiled vars:  !0 = $string, !1 = $search, !2 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'bla+bla+xxx+bla+%2Axxx+bla+bla+%2A%2Axxx+bla+bla+%2A%2A%2Axxx+bla+bla+%2A%2A%2A%2Axxx'
    4     1        ASSIGN                                                   !1, 'xxx'
    5     2        ASSIGN                                                   !2, '%2A'
    7     3        INIT_FCALL                                               'preg_replace_callback'
    8     4        INIT_FCALL                                               'preg_quote'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $6      
          7        CONCAT                                           ~7      '%2F%28', $6
          8        CONCAT                                           ~8      ~7, '%2A%29%28'
          9        CONCAT                                           ~9      ~8, !1
         10        CONCAT                                           ~10     ~9, '%29%2F'
         11        SEND_VAL                                                 ~10
    9    12        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
   17    13        SEND_VAL                                                 ~11
   18    14        SEND_VAR                                                 !0
    7    15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !0, $12
   21    17        ECHO                                                     !0
         18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tZKOF
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $matches, !1 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        BIND_GLOBAL                                              !1, 'char'
   11     2        FETCH_DIM_R                                      ~2      !0, 1
          3        STRLEN                                           ~3      ~2
          4        MOD                                              ~4      ~3, 2
          5        IS_IDENTICAL                                             ~4, 0
          6      > JMPZ                                                     ~5, ->13
   12     7    >   FETCH_DIM_R                                      ~6      !0, 1
          8        CONCAT                                           ~7      ~6, !1
          9        FETCH_DIM_R                                      ~8      !0, 2
         10        CONCAT                                           ~9      ~7, ~8
         11      > RETURN                                                   ~9
   11    12*       JMP                                                      ->15
   14    13    >   FETCH_DIM_R                                      ~10     !0, 0
         14      > RETURN                                                   ~10
   17    15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.55 ms | 1012 KiB | 15 Q