3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is my test string {ABC}. This is test {XYZ}. I am new for PHP {PHP}". $i = 1; echo preg_replace_callback('/\{(.+?)\}/', function (array $match) use (&$i) { return sprintf('{%s %d}', $match[1], $i++); }, $string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hlvKA
function name:  (null)
number of ops:  12
compiled vars:  !0 = $string, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                           ~2      !1, 1
          1        CONCAT                                           ~3      'This+is+my+test+string+%7BABC%7D.+This+is+test+%7BXYZ%7D.+I+am+new+for+PHP+%7BPHP%7D', ~2
    3     2        ASSIGN                                                   !0, ~3
    6     3        INIT_FCALL                                               'preg_replace_callback'
          4        SEND_VAL                                                 '%2F%5C%7B%28.%2B%3F%29%5C%7D%2F'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhlvKA%3A6%240'
          6        BIND_LEXICAL                                             ~5, !1
    8     7        SEND_VAL                                                 ~5
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        ECHO                                                     $6
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FhlvKA%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hlvKA
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $match, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 '%7B%25s+%25d%7D'
          4        FETCH_DIM_R                                      ~2      !0, 1
          5        SEND_VAL                                                 ~2
          6        POST_INC                                         ~3      !1
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
    8    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FhlvKA%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.07 ms | 1387 KiB | 17 Q