3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html1 = <<<EOT <option selected="selected" value="1">value text</option> EOT; $html2 = <<<EOT <option selected value="1">value text</option> EOT; $html3 = <<<EOT <option value="the devil with **selected** ">value text</option> EOT; $html4 = <<<EOT <option selected="selected" value="1">value text</option> <option value="the devil with **selected** ">value text</option> <option selected value="1">value text</option> EOT; function get_selected($html) { $results = array(); $doc = new DOMDocument; $doc->loadHTML($html); $xpath = new DOMXpath($doc); foreach ($xpath->query("//option") as $option) { $selected_value = $xpath->evaluate('string(@selected)', $option); $results[] = $selected_value; } return $results; } var_dump( '1', get_selected($html1) ); var_dump( '2, gget_selected($html2) ); var_dump( '3', gget_selected($html3) ); var_dump( '4', gget_selected($html4) );

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)
7.0.10.0170.07320.10
7.0.00.0030.04320.08
5.6.160.0030.05320.43
5.6.150.0070.05018.18
5.6.140.0070.06718.12
5.6.130.0030.05718.19
5.6.120.0130.07720.90
5.6.110.0030.04021.02
5.6.100.0100.08021.11
5.6.90.0030.06720.99
5.6.80.0130.07720.51
5.5.300.0070.05317.99
5.5.290.0070.06717.92
5.5.280.0130.07320.80
5.5.270.0070.07720.68
5.5.260.0200.06320.95
5.5.250.0130.07020.79
5.5.240.0230.07020.27

preferences:
149.2 ms | 1386 KiB | 7 Q