3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = "Made in Switzerland, this stainless steel watch has single and double wrap interchangeable leather straps and is water resistant up to 30 meters<br><p><br></p>"; // $html = "<p>some thing</p>shitty p stuff<p>correct</p>\r\n<p>what about this</p>this is not correct\n"; // $html = "<p>some thing</p><p>shitty p stuff</p><p>correct</p><p>what about this</p>this is not correct"; // $html = "<p><a href=\"http://www.beataheuman.com/shop/\" title=\"www.beataheuman.com\">www.beataheuman.com</a>.</p><br />"; // $html = "ptest"; var_dump($html); // add <p></p> to the text if missing var_dump($html); // fix not closed paragraphs // $html = preg_replace('~(<p>.*?)([^</p>]<p>)~', '$1</p><p>', $html); var_dump($html); $html = preg_replace('~(\r\n|\n|\r)~s', '', $html); var_dump($html); // add into p the text in between paragraphs $html = preg_replace('~</p>([^<p>].+?)<p>~', '</p><p>$1</p><p>', $html); var_dump($html); // add into p the text after the last paragraph $html = preg_replace('~</p>((?!<p>).+)?$~Ds', '</p><p>$1</p>', $html, 1); var_dump($html); $html = preg_replace('~<p>(\W*)</p>~', '', $html); // $html = preg_replace('~^(<p>)?((?!</p>).*)(</p>)?$~A', '<p>$2</p>', $html); // if ($pPos = strpos($html, '<p>')) { // $html = '<p>' . substr($html, . '</p>'; // } // fix &nbsp; $html = html_entity_decode($html, null, 'UTF-8'); // change & to &amp; $html = preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $html); $paragraphPosition = strpos($html, '<p>'); if (0 !== $paragraphPosition) { $html = '<p>' . substr($html, 0, $paragraphPosition) . '</p>' . substr($html, $paragraphPosition); } var_dump($html);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 76
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
filename:       /in/igRGr
function name:  (null)
number of ops:  80
compiled vars:  !0 = $html, !1 = $paragraphPosition
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Made+in+Switzerland%2C+this+stainless+steel+watch+has+single+and+double+wrap+interchangeable+leather+straps+and+is+water+resistant+up+to+30+meters%3Cbr%3E%3Cp%3E%3Cbr%3E%3C%2Fp%3E'
    7     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    9     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   13     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   15    10        INIT_FCALL                                               'preg_replace'
         11        SEND_VAL                                                 '%7E%28%5Cr%5Cn%7C%5Cn%7C%5Cr%29%7Es'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !0, $6
   16    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   20    19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%7E%3C%2Fp%3E%28%5B%5E%3Cp%3E%5D.%2B%3F%29%3Cp%3E%7E'
         21        SEND_VAL                                                 '%3C%2Fp%3E%3Cp%3E%241%3C%2Fp%3E%3Cp%3E'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $9      
         24        ASSIGN                                                   !0, $9
   21    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
   24    28        INIT_FCALL                                               'preg_replace'
         29        SEND_VAL                                                 '%7E%3C%2Fp%3E%28%28%3F%21%3Cp%3E%29.%2B%29%3F%24%7EDs'
         30        SEND_VAL                                                 '%3C%2Fp%3E%3Cp%3E%241%3C%2Fp%3E'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 1
         33        DO_ICALL                                         $12     
         34        ASSIGN                                                   !0, $12
   25    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                                 
   27    38        INIT_FCALL                                               'preg_replace'
         39        SEND_VAL                                                 '%7E%3Cp%3E%28%5CW%2A%29%3C%2Fp%3E%7E'
         40        SEND_VAL                                                 ''
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                         $15     
         43        ASSIGN                                                   !0, $15
   35    44        INIT_FCALL                                               'html_entity_decode'
         45        SEND_VAR                                                 !0
         46        SEND_VAL                                                 null
         47        SEND_VAL                                                 'UTF-8'
         48        DO_ICALL                                         $17     
         49        ASSIGN                                                   !0, $17
   38    50        INIT_FCALL                                               'preg_replace'
         51        SEND_VAL                                                 '%2F%26%28%3F%21%23%3F%5Ba-z0-9%5D%2B%3B%29%2F'
         52        SEND_VAL                                                 '%26amp%3B'
         53        SEND_VAR                                                 !0
         54        DO_ICALL                                         $19     
         55        ASSIGN                                                   !0, $19
   40    56        INIT_FCALL                                               'strpos'
         57        SEND_VAR                                                 !0
         58        SEND_VAL                                                 '%3Cp%3E'
         59        DO_ICALL                                         $21     
         60        ASSIGN                                                   !1, $21
   42    61        IS_NOT_IDENTICAL                                         !1, 0
         62      > JMPZ                                                     ~23, ->76
   43    63    >   INIT_FCALL                                               'substr'
         64        SEND_VAR                                                 !0
         65        SEND_VAL                                                 0
         66        SEND_VAR                                                 !1
         67        DO_ICALL                                         $24     
         68        CONCAT                                           ~25     '%3Cp%3E', $24
         69        CONCAT                                           ~26     ~25, '%3C%2Fp%3E'
         70        INIT_FCALL                                               'substr'
         71        SEND_VAR                                                 !0
         72        SEND_VAR                                                 !1
         73        DO_ICALL                                         $27     
         74        CONCAT                                           ~28     ~26, $27
         75        ASSIGN                                                   !0, ~28
   46    76    >   INIT_FCALL                                               'var_dump'
         77        SEND_VAR                                                 !0
         78        DO_ICALL                                                 
         79      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.35 ms | 945 KiB | 24 Q