3v4l.org

run code in 300+ PHP versions simultaneously
<?php $htmls = [ "<p><div><p>aaaaaa</p></div></p>", "<div><p>aaaaaa</p></div>", "<p>aaaaaa</p><div>bbbbbb</div>", "<p>aaaaaa</p><div>bbbbbb</div><p>cccccc</p>", "<p>aaaaaa</p><p>bbbbbb</p>", "<p>hello<p>aaaaaa</p></p>", "<p><p>aaaaaa</p></p>" ]; foreach ($htmls as $i => $html) { $without_ptags = preg_replace('~<p>(?:(?R)|.*?)*</p>~', '', $html, 2, $count); if ($without_ptags === '' && $count == 1) { echo "$i => ", substr($html, 3, -4); }else{ echo "$i => not wrapped in p tags"; } echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 32
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/fSZOh
function name:  (null)
number of ops:  34
compiled vars:  !0 = $htmls, !1 = $html, !2 = $i, !3 = $without_ptags, !4 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $6      !0, ->32
          2    > > FE_FETCH_R                                       ~7      $6, !1, ->32
          3    >   ASSIGN                                                   !2, ~7
   13     4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%7E%3Cp%3E%28%3F%3A%28%3FR%29%7C.%2A%3F%29%2A%3C%2Fp%3E%7E'
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 2
          9        SEND_REF                                                 !4
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !3, $9
   14    12        IS_IDENTICAL                                     ~11     !3, ''
         13      > JMPZ_EX                                          ~11     ~11, ->16
         14    >   IS_EQUAL                                         ~12     !4, 1
         15        BOOL                                             ~11     ~12
         16    > > JMPZ                                                     ~11, ->27
   15    17    >   NOP                                                      
         18        FAST_CONCAT                                      ~13     !2, '+%3D%3E+'
         19        ECHO                                                     ~13
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !1
         22        SEND_VAL                                                 3
         23        SEND_VAL                                                 -4
         24        DO_ICALL                                         $14     
         25        ECHO                                                     $14
   14    26      > JMP                                                      ->30
   17    27    >   NOP                                                      
         28        FAST_CONCAT                                      ~15     !2, '+%3D%3E+not+wrapped+in+p+tags'
         29        ECHO                                                     ~15
   19    30    >   ECHO                                                     '%0A---%0A'
   12    31      > JMP                                                      ->2
         32    >   FE_FREE                                                  $6
   20    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.93 ms | 1012 KiB | 15 Q