3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sentence = '[html style="font-size: 18px;" dir="ltr"][div style="font-size: 18px;" dir="ltr"][p style="font-weight: bold;"]Hello,[/p][p]You have got a new message from [a href="https://www.example.com/"]Example.com[/a][br][br].You could check your message on [a href="https://www.example.com/en/manager/inbox.html"]Manager[/a][/p][p][img src="https://www.example.com/assets/images/logo-default-120x50.png" width="120px" height="80px"][div style="color: #D4192D; font-weight: bold;"]Example.com Team[/div][/p][/div][/html]'; $rx = '~\[((\w+)\b[^]]*)\]((?>(?!\[\2\b).|(?R))*)\[\/\2]~s'; $tmp = ''; while (preg_match($rx, $sentence) && $tmp != $sentence) { $tmp = $sentence; $sentence = preg_replace($rx, '<$1>$3</$2>', $sentence); } $sentence = preg_replace('~\[([^]]*)]~', '<$1 />', $sentence); echo $sentence;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 4
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
Branch analysis from position: 18
Branch analysis from position: 18
filename:       /in/WcWuu
function name:  (null)
number of ops:  27
compiled vars:  !0 = $sentence, !1 = $rx, !2 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5Bhtml+style%3D%22font-size%3A+18px%3B%22+dir%3D%22ltr%22%5D%5Bdiv+style%3D%22font-size%3A+18px%3B%22+dir%3D%22ltr%22%5D%5Bp+style%3D%22font-weight%3A+bold%3B%22%5DHello%2C%5B%2Fp%5D%5Bp%5DYou+have+got+a+new+message+from+%5Ba+href%3D%22https%3A%2F%2Fwww.example.com%2F%22%5DExample.com%5B%2Fa%5D%5Bbr%5D%5Bbr%5D.You+could+check+your+message+on+%5Ba+href%3D%22https%3A%2F%2Fwww.example.com%2Fen%2Fmanager%2Finbox.html%22%5DManager%5B%2Fa%5D%5B%2Fp%5D%5Bp%5D%5Bimg+src%3D%22https%3A%2F%2Fwww.example.com%2Fassets%2Fimages%2Flogo-default-120x50.png%22+width%3D%22120px%22+height%3D%2280px%22%5D%5Bdiv+style%3D%22color%3A+%23D4192D%3B+font-weight%3A+bold%3B%22%5DExample.com+Team%5B%2Fdiv%5D%5B%2Fp%5D%5B%2Fdiv%5D%5B%2Fhtml%5D'
    5     1        ASSIGN                                                   !1, '%7E%5C%5B%28%28%5Cw%2B%29%5Cb%5B%5E%5D%5D%2A%29%5C%5D%28%28%3F%3E%28%3F%21%5C%5B%5C2%5Cb%29.%7C%28%3FR%29%29%2A%29%5C%5B%5C%2F%5C2%5D%7Es'
    6     2        ASSIGN                                                   !2, ''
    7     3      > JMP                                                      ->11
    8     4    >   ASSIGN                                                   !2, !0
    9     5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 '%3C%241%3E%243%3C%2F%242%3E'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !0, $7
    7    11    >   INIT_FCALL                                               'preg_match'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $9      
         15      > JMPZ_EX                                          ~10     $9, ->18
         16    >   IS_NOT_EQUAL                                     ~11     !2, !0
         17        BOOL                                             ~10     ~11
         18    > > JMPNZ                                                    ~10, ->4
   11    19    >   INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%7E%5C%5B%28%5B%5E%5D%5D%2A%29%5D%7E'
         21        SEND_VAL                                                 '%3C%241+%2F%3E'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $12     
         24        ASSIGN                                                   !0, $12
   12    25        ECHO                                                     !0
   13    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.07 ms | 1396 KiB | 17 Q