3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = null; $c = 1; $r = preg_replace_callback('@/(<p( [^>]+)?>)/i@', function ($res) { global $c; return '<p'.$res[2].' id="'.intval($c++).'">'; }, $text); $r = preg_replace('/(<p.*?)id="'.($c-1).'"(>)/i', '\1id="Last"\2', $r); $text = $r; echo $text;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ehqRC
function name:  (null)
number of ops:  21
compiled vars:  !0 = $text, !1 = $c, !2 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, null
    3     1        ASSIGN                                                   !1, 1
    4     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%40%2F%28%3Cp%28+%5B%5E%3E%5D%2B%29%3F%3E%29%2Fi%40'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FehqRC%3A4%240'
    7     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
    4     8        ASSIGN                                                   !2, $6
    8     9        INIT_FCALL                                               'preg_replace'
         10        SUB                                              ~8      !1, 1
         11        CONCAT                                           ~9      '%2F%28%3Cp.%2A%3F%29id%3D%22', ~8
         12        CONCAT                                           ~10     ~9, '%22%28%3E%29%2Fi'
         13        SEND_VAL                                                 ~10
         14        SEND_VAL                                                 '%5C1id%3D%22Last%22%5C2'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !2, $11
    9    18        ASSIGN                                                   !0, !2
   10    19        ECHO                                                     !0
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FehqRC%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ehqRC
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $res, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        BIND_GLOBAL                                              !1, 'c'
    6     2        FETCH_DIM_R                                      ~2      !0, 2
          3        CONCAT                                           ~3      '%3Cp', ~2
          4        CONCAT                                           ~4      ~3, '+id%3D%22'
          5        POST_INC                                         ~5      !1
          6        CAST                                          4  ~6      ~5
          7        CONCAT                                           ~7      ~4, ~6
          8        CONCAT                                           ~8      ~7, '%22%3E'
          9      > RETURN                                                   ~8
    7    10*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.15 ms | 1396 KiB | 17 Q