3v4l.org

run code in 300+ PHP versions simultaneously
<?php $resultApi = '<fieldset class="relative"> <div> <h5><button>CABIN #1</button></h5> </div> <div>EMPTY</div> </fieldset> <fieldset class="relative"> <div> <h5><button>CABIN #2</button></h5> </div> <div> <select data-id="222"> <option value="1">Op#1</option> <option value="2">Op#2</option> </select> </div> </fieldset> <fieldset class="relative"> <div> <h5><button>CABIN #3</button></h5> </div> <div> <select data-id="223"> <option value="1">Op#1</option> <option value="2">Op#2</option> <option value="3">Op#3</option> </select> </div> </fieldset>'; $dom = new \DOMDocument(); @$dom->loadHTML($resultApi); // Create a DOMXPath instance and locate elements $xpath = new \DOMXPath($dom); $items = $xpath->query("//fieldset[@class='relative']"); $result = []; foreach ($items as $node) { $title = $xpath->query('.//following-sibling::h5/button', $node)->item(0)->nodeValue; $div = $xpath->query('.//following-sibling::select', $node); $result[$title]= 0; if($div->length){ foreach ($div as $option) { $children = $option->childNodes; $countOp = 1; foreach ($children as $child) { if($child->nodeName === 'option' && $child->nodeValue !== '-'){ $result[$title]= $countOp++; } } } } } print_r($result);

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.5.00.0140.00920.50
8.4.150.0030.00014.05
8.4.140.0100.01217.89
8.4.130.0140.00718.11
8.4.120.0100.01120.84
8.4.110.0130.00819.00
8.4.100.0120.01018.17
8.4.90.0120.00818.34
8.4.80.0150.00620.01
8.4.70.0110.00520.12
8.4.60.0350.01117.97
8.4.50.0380.01017.88
8.4.40.0390.01117.96
8.4.30.0410.00917.76
8.4.20.0410.01017.62
8.4.10.0390.01117.82
8.3.280.0120.01018.75
8.3.270.0130.00617.06
8.3.260.0120.00717.27
8.3.250.0070.00319.17
8.3.240.0150.00517.16
8.3.230.0130.00617.29
8.3.220.0100.00918.61
8.3.210.0090.01017.00
8.3.200.0300.01516.71
8.3.190.0340.01116.83
8.3.180.0280.00716.97
8.3.170.0440.00816.78
8.3.160.0370.01117.01
8.3.150.0380.01016.82
8.3.140.0340.01416.56
8.3.130.0320.01017.05
8.3.120.0320.01116.83
8.3.110.0310.01116.88
8.3.100.0370.00716.80
8.3.90.0260.00417.00
8.3.80.0430.00616.72
8.3.70.0390.00916.79
8.3.60.0410.00816.69
8.3.50.0480.00916.86
8.3.40.0360.01217.85
8.3.30.0320.01217.64
8.3.20.0270.00917.96
8.3.10.0290.01117.85
8.3.00.0180.01017.84
8.2.290.0130.00619.18
8.2.280.0290.00917.11
8.2.270.0240.01516.75
8.2.260.0330.00616.77
8.2.250.0310.00916.84
8.2.240.0340.01016.57
8.2.230.0310.01416.47
8.2.220.0210.00516.96
8.2.210.0200.00716.30
8.2.200.0310.00416.97
8.2.190.0160.00216.77
8.2.180.0170.00316.87
8.2.170.0140.00518.15
8.2.160.0160.00318.02
8.2.150.0170.00318.01
8.2.140.0180.00417.91
8.2.130.0350.00817.91
8.2.120.0320.01017.86
8.2.110.0340.00917.86
8.2.100.0340.00717.84
8.2.90.0310.01117.79
8.2.80.0360.00917.85
8.2.70.0320.01117.79
8.2.60.0360.00718.05
8.2.50.0340.01017.68
8.2.40.0420.00617.96
8.2.30.0360.00817.89
8.2.20.0260.01217.76
8.2.10.0290.01018.00
8.2.00.0330.00517.80

preferences:
48.8 ms | 403 KiB | 5 Q