3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $input) { $doc = new DOMDocument; $doc->loadHTML( $input); $p = $doc->getElementsByTagName('p')->item(0); $children = $p->childNodes; $img_found = false; $error = false; foreach( $children as $child) { if( $child->nodeType == XML_TEXT_NODE && !$img_found) { // Text before the image, OK, continue on continue; } if( $child->nodeType == XML_ELEMENT_NODE) { if( !($child->tagName == 'img')) { // echo "Invalid HTML element found"; $error = true; } else { $img_found = true; } } else { // echo "Invalid node type!"; $error = true; } } if( $img_found && !$error) { echo 'ok' . "\n"; } else { echo 'NOT ok' . "\n"; } } $input = ' <a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/Interschool-championship.gif"><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg"><img class="aligncenter size-full wp-image-1928" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg" width="1024" height="768" /></a><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg"><img class="aligncenter size-full wp-image-1929" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg" width="1024" height="768" /></a></a>'; // ok test( $input);

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.40.0060.01219.05
8.3.30.0110.00319.52
8.3.20.0000.00820.55
8.3.10.0000.00824.08
8.3.00.0040.00421.19
8.2.170.0120.00322.96
8.2.160.0070.00720.59
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00021.36
8.2.110.0030.00620.67
8.2.100.0120.00018.10
8.2.90.0080.00018.41
8.2.80.0000.00817.97
8.2.70.0040.00417.75
8.2.60.0090.00018.30
8.2.50.0030.00618.07
8.2.40.0030.00621.37
8.2.30.0000.00818.38
8.2.20.0000.00917.98
8.2.10.0040.00418.36
8.2.00.0100.00018.20
8.1.270.0030.00624.04
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.31
8.1.230.0070.00421.29
8.1.220.0030.00518.14
8.1.210.0000.00819.33
8.1.200.0060.00317.50
8.1.190.0080.00017.60
8.1.180.0060.00318.10
8.1.170.0000.00818.60
8.1.160.0040.00422.29
8.1.150.0040.00419.04
8.1.140.0040.00417.62
8.1.130.0000.00718.09
8.1.120.0050.00317.64
8.1.110.0080.00017.62
8.1.100.0040.00417.65
8.1.90.0000.00817.77
8.1.80.0000.00817.71
8.1.70.0000.00717.60
8.1.60.0060.00317.83
8.1.50.0000.00917.71
8.1.40.0000.00817.75
8.1.30.0030.00517.88
8.1.20.0000.00817.92
8.1.10.0040.00417.81
8.1.00.0030.00717.68
8.0.300.0040.00420.30
8.0.290.0000.00717.30
8.0.280.0030.00318.61
8.0.270.0000.00717.38
8.0.260.0000.00617.52
8.0.250.0000.00717.15
8.0.240.0060.00317.27
8.0.230.0030.00317.21
8.0.220.0030.00517.24
8.0.210.0030.00317.21
8.0.200.0030.00317.14
8.0.190.0030.00517.27
8.0.180.0040.00417.21
8.0.170.0040.00417.10
8.0.160.0000.00717.17
8.0.150.0030.00317.09
8.0.140.0040.00417.07
8.0.130.0040.00413.68
8.0.120.0040.00417.05
8.0.110.0040.00417.13
8.0.100.0000.00717.23
8.0.90.0020.00517.03
8.0.80.0080.00817.17
8.0.70.0020.00516.97
8.0.60.0030.00517.02
8.0.50.0000.00717.34
8.0.30.0090.01217.35
8.0.20.0110.00917.45
8.0.10.0030.00517.17
8.0.00.0120.00816.96
7.4.330.0000.00515.00
7.4.320.0060.00016.88
7.4.300.0030.00316.78
7.4.290.0000.00716.62
7.4.280.0000.00916.86
7.4.270.0000.00716.73
7.4.260.0000.00816.84
7.4.250.0020.00516.91
7.4.240.0050.00316.85
7.4.230.0000.00716.76
7.4.220.0120.00616.70
7.4.210.0110.00416.87
7.4.200.0040.00416.54
7.4.190.0050.00216.94
7.4.160.0070.01116.82
7.4.150.0130.00717.40
7.4.140.0070.01117.86
7.4.130.0120.00816.80
7.4.120.0120.00516.81
7.4.110.0090.00916.82
7.4.100.0170.00616.97
7.4.90.0040.01316.71
7.4.80.0110.01119.39
7.4.70.0060.01016.77
7.4.60.0050.01016.76
7.4.50.0040.00416.57
7.4.40.0060.00916.82
7.4.30.0080.00816.54
7.4.00.0040.00915.12
7.3.330.0050.00013.65
7.3.320.0030.00313.56
7.3.310.0030.00316.69
7.3.300.0000.00816.69
7.3.290.0040.01116.62
7.3.280.0090.00916.64
7.3.270.0090.00917.40
7.3.260.0080.01216.84
7.3.250.0120.00816.81
7.3.240.0090.00916.80
7.3.230.0120.00616.66
7.3.210.0070.01016.62
7.3.200.0100.01319.39
7.3.190.0140.00416.80
7.3.180.0130.00916.62
7.3.170.0060.01016.75
7.3.160.0000.01716.60
7.3.120.0000.01314.93
7.2.330.0060.01216.66
7.2.320.0170.00616.99
7.2.310.0070.01116.76
7.2.300.0080.00817.00
7.2.290.0130.01016.84
7.1.200.0070.00415.66
7.1.70.0000.00717.19
7.1.60.0130.01319.46
7.1.50.0060.01616.83
7.1.00.0100.07022.38
7.0.200.0000.00816.98
7.0.140.0030.07322.12
7.0.60.0070.04019.89
7.0.50.0100.07017.98
7.0.40.0000.08320.23
7.0.30.0270.04320.29
7.0.20.0230.07020.18
7.0.10.0200.07320.29
7.0.00.0100.08720.33
5.6.280.0000.07320.95
5.6.210.0170.07320.55
5.6.200.0070.04018.32
5.6.190.0100.06320.41
5.6.180.0470.06320.54
5.6.170.0130.06020.61
5.6.160.0070.04320.52
5.6.150.0200.07018.29
5.6.140.0030.05318.21
5.6.130.0130.03718.25
5.6.120.0000.08020.79
5.6.110.0200.07321.03
5.6.100.0200.07721.16
5.6.90.0170.08021.19
5.6.80.0100.03320.52
5.5.350.0300.07020.48
5.5.340.0100.07318.12
5.5.330.0070.05320.38
5.5.320.0170.04720.32
5.5.310.0330.07320.42
5.5.300.0100.07718.07
5.5.290.0100.08018.00
5.5.280.0070.07320.92
5.5.270.0100.04020.80
5.5.260.0130.04020.92
5.5.250.0030.04320.83
5.5.240.0230.07320.31
5.4.450.0570.07019.32
5.4.440.0470.03319.44
5.4.430.0270.04019.37
5.4.420.0270.03719.63
5.4.410.0230.04719.47
5.4.400.0600.03319.21
5.4.390.0500.03719.30
5.4.380.0230.06018.85
5.4.370.0570.07318.61
5.4.360.0370.06018.88
5.4.350.0530.04718.78
5.4.340.0430.05318.78
5.4.320.0070.03812.66
5.4.310.0100.05212.66
5.4.300.0050.03912.66
5.4.290.0090.04512.66
5.4.280.0060.05112.56
5.4.270.0110.03812.55
5.4.260.0060.04112.55
5.4.250.0070.04012.55
5.4.240.0080.04312.55
5.4.230.0110.04812.55
5.4.220.0120.04612.55
5.4.210.0180.04512.55
5.4.200.0120.05312.54
5.4.190.0120.05312.55
5.4.180.0140.05212.54
5.4.170.0090.05812.55
5.4.160.0170.04812.55
5.4.150.0130.05112.54
5.4.140.0110.04812.23
5.4.130.0060.04812.21
5.4.120.0140.04812.17
5.4.110.0070.05212.16
5.4.100.0110.04612.17
5.4.90.0090.05612.17
5.4.80.0080.05312.16
5.4.70.0130.04612.16
5.4.60.0090.05212.17
5.4.50.0110.05012.16
5.4.40.0090.05512.16
5.4.30.0070.05112.15
5.4.20.0100.05112.15
5.4.10.0180.05912.15
5.4.00.0110.05011.63
5.3.290.0070.03912.92
5.3.280.0130.04812.85
5.3.270.0150.04912.86
5.3.260.0110.05312.86
5.3.250.0100.06412.86
5.3.240.0160.04912.86
5.3.230.0120.03812.85
5.3.220.0070.04212.82
5.3.210.0060.04112.82
5.3.200.0150.04512.82
5.3.190.0080.05012.82
5.3.180.0120.04712.82
5.3.170.0080.04812.82
5.3.160.0060.04212.82
5.3.150.0040.04212.82
5.3.140.0070.03512.81
5.3.130.0070.03712.80
5.3.120.0110.03412.80
5.3.110.0060.04112.80
5.3.100.0080.04012.29
5.3.90.0060.03712.27
5.3.80.0050.03712.27
5.3.70.0060.03612.26
5.3.60.0070.03512.25
5.3.50.0080.03412.20
5.3.40.0050.03812.20
5.3.30.0080.03412.15
5.3.20.0090.03311.94
5.3.10.0100.03311.90
5.3.00.0110.03511.89
5.2.170.0050.0319.40
5.2.160.0020.0339.40
5.2.150.0090.0279.40
5.2.140.0070.0299.39
5.2.130.0080.0299.35
5.2.120.0070.0309.36
5.2.110.0040.0309.36
5.2.100.0040.0309.35
5.2.90.0070.0279.35
5.2.80.0070.0299.34
5.2.70.0020.0439.35
5.2.60.0030.0449.30
5.2.50.0110.0369.27
5.2.40.0040.0409.25
5.2.30.0070.0409.22
5.2.20.0080.0369.20
5.2.10.0070.0369.11
5.2.00.0070.0338.97
5.1.60.0050.0258.25
5.1.50.0060.0278.25
5.1.40.0050.0358.23
5.1.30.0070.0358.58
5.1.20.0050.0368.60
5.1.10.0070.0358.32
5.1.00.0020.0288.33
5.0.50.0060.0196.82
5.0.40.0020.0216.69
5.0.30.0060.0306.50
5.0.20.0030.0206.46
5.0.10.0040.0206.45
5.0.00.0040.0306.44
4.4.90.0020.0174.78
4.4.80.0060.0124.75
4.4.70.0030.0194.75
4.4.60.0030.0194.75
4.4.50.0000.0224.77
4.4.40.0050.0234.71
4.4.30.0020.0164.75
4.4.20.0040.0154.84
4.4.10.0040.0154.85
4.4.00.0020.0264.76
4.3.110.0040.0144.67
4.3.100.0020.0164.66
4.3.90.0030.0144.63
4.3.80.0040.0234.59
4.3.70.0030.0144.63
4.3.60.0020.0154.63
4.3.50.0020.0164.62
4.3.40.0010.0264.54
4.3.30.0020.0163.30
4.3.20.0030.0153.27
4.3.10.0010.0163.25
4.3.00.0130.02016.14

preferences:
58.92 ms | 400 KiB | 5 Q