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>$2</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);
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(166) "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><p></p>" Deprecated: html_entity_decode(): Passing null to parameter #2 ($flags) of type int is deprecated in /in/HXVQD on line 35 string(166) "<p>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><p><br></p>"
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(166) "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><p></p>" Deprecated: html_entity_decode(): Passing null to parameter #2 ($flags) of type int is deprecated in /in/HXVQD on line 35 string(166) "<p>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><p><br></p>"
Output for 5.6.0 - 5.6.27, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(159) "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>" string(166) "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><p></p>" string(166) "<p>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><p><br></p>"

preferences:
220.82 ms | 405 KiB | 232 Q