3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "/companies/(?)/adverts/new/(?)"; $replace = array(2223, 'generic'); $result = preg_replace_callback('#(\(\?\))#', function($m) use ($replace) { static $i=0; return $replace[$i++]; }, $string); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v5QGl
function name:  (null)
number of ops:  14
compiled vars:  !0 = $string, !1 = $replace, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Fcompanies%2F%28%3F%29%2Fadverts%2Fnew%2F%28%3F%29'
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%23%28%5C%28%5C%3F%5C%29%29%23'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fv5QGl%3A6%240'
          5        BIND_LEXICAL                                             ~5, !1
   10     6        SEND_VAL                                                 ~5
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
    6     9        ASSIGN                                                   !2, $6
   12    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fv5QGl%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v5QGl
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m, !1 = $replace, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        BIND_STATIC                                              !2
    9     3        POST_INC                                         ~3      !2
          4        FETCH_DIM_R                                      ~4      !1, ~3
          5      > RETURN                                                   ~4
   10     6*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.71 ms | 1395 KiB | 17 Q