3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validateHtml($html) { $stack = array(); $tags = preg_split("/(<[^>]+>)/", $html, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($tags as $tag) { if (preg_match("/^<\/\s*([^\s>]+)\s*>$/", $tag, $matches)) { // closing tag $last = array_pop($stack); if (!$last || $last !== $matches[1]) { return false; } } elseif (preg_match("/^<\s*([^\s>]+)(\s+[^>]+)?\s*>$/", $tag, $matches)) { // opening tag array_push($stack, $matches[1]); } } return count($stack) === 0; } // example usage $html = "<div><p>Some text</p></div>"; var_dump(validateHtml($html)); // true $html = "<div><p>Some text</div>"; var_dump(validateHtml($html)); // false $html = "<div><p>Some text</p><span></span></div>"; var_dump(validateHtml($html)); // true $html = "<div><p>Some text<span></p></span></div>"; var_dump(validateHtml($html)); // false

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0180.00418.68
8.3.60.0090.00920.16
8.3.50.0040.01816.80
8.3.40.0060.00920.52
8.3.30.0030.01020.21
8.3.20.0000.00824.18
8.3.10.0080.00024.66
8.3.00.0040.00426.16
8.2.190.0060.00917.00
8.2.180.0090.00616.50
8.2.170.0100.01019.05
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0090.00022.09
8.2.110.0110.00022.04
8.2.100.0090.00020.47
8.1.280.0040.01825.92
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00320.49
8.1.230.0080.00318.95
8.1.60.0060.00379.33

preferences:
19.63 ms | 401 KiB | 5 Q