3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<div class="something">What </div> if it it is is same <div style="color:red;">same </div>'; echo preg_replace_callback('~</?\b[^<>]+>(*SKIP)(*F)|\w+~', function($matches) { static $counter = 0; return "<span class=\"splits split".(++$counter)."\">{$matches[0]}</span>"; }, $string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUgbn
function name:  (null)
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+class%3D%22something%22%3EWhat+%3C%2Fdiv%3E+if+it+it+is+is+same+%3Cdiv+style%3D%22color%3Ared%3B%22%3Esame+%3C%2Fdiv%3E'
    5     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%7E%3C%2F%3F%5Cb%5B%5E%3C%3E%5D%2B%3E%28%2ASKIP%29%28%2AF%29%7C%5Cw%2B%7E'
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    8     4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
    5     6        DO_ICALL                                         $3      
    8     7        ECHO                                                     $3
          8      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qUgbn
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $matches, !1 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        BIND_STATIC                                              !1
    7     2        PRE_INC                                          ~2      !1
          3        CONCAT                                           ~3      '%3Cspan+class%3D%22splits+split', ~2
          4        ROPE_INIT                                     3  ~6      '%22%3E'
          5        FETCH_DIM_R                                      ~4      !0, 0
          6        ROPE_ADD                                      1  ~6      ~6, ~4
          7        ROPE_END                                      2  ~5      ~6, '%3C%2Fspan%3E'
          8        CONCAT                                           ~8      ~3, ~5
          9      > RETURN                                                   ~8
    8    10*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.27 ms | 1010 KiB | 14 Q