3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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/B2WQ4
function name:  (null)
number of ops:  20
compiled vars:  !0 = $c, !1 = $r, !2 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 1
    3     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%28%3Cp%28+%5B%5E%3E%5D%2B%29%3F%3E%29%2Fi'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FB2WQ4%3A3%240'
    6     4        SEND_VAL                                                 ~4
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $5      
    3     7        ASSIGN                                                   !1, $5
    7     8        INIT_FCALL                                               'preg_replace'
          9        SUB                                              ~7      !0, 1
         10        CONCAT                                           ~8      '%2F%28%3Cp.%2A%3F%29id%3D%22', ~7
         11        CONCAT                                           ~9      ~8, '%22%28%3E%29%2Fi'
         12        SEND_VAL                                                 ~9
         13        SEND_VAL                                                 '%5C1id%3D%22Last%22%5C2'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !1, $10
    8    17        ASSIGN                                                   !2, !1
    9    18        ECHO                                                     !2
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FB2WQ4%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B2WQ4
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $res, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        BIND_GLOBAL                                              !1, 'c'
    5     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
    6    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FB2WQ4%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.11 ms | 1396 KiB | 17 Q