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 href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0838.jpg"> <img class="aligncenter size-full wp-image-1931" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0838.jpg" width="1024" height="768" /> </a> <a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0841.jpg"> <img class="aligncenter size-full wp-image-1932" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0841.jpg" width="1024" height="768" /> </a> <a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0872.jpg"> <img class="aligncenter size-full wp-image-1934" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0872.jpg" width="1024" height="768" /> </a> <a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0884.jpg"> <img class="aligncenter size-full wp-image-1935" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0884.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.60.0100.01017.13
8.3.50.0140.00322.12
8.3.40.0090.00618.98
8.3.30.0000.01419.39
8.3.20.0080.00020.59
8.3.10.0080.00023.73
8.3.00.0080.00019.44
8.2.180.0090.00617.13
8.2.170.0120.00322.96
8.2.160.0100.00720.63
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00726.16
8.2.120.0030.00520.93
8.2.110.0040.00422.45
8.2.100.0130.00017.97
8.2.90.0080.00019.48
8.2.80.0050.00318.00
8.2.70.0030.00617.75
8.2.60.0050.00318.05
8.2.50.0040.00418.07
8.2.40.0000.00821.38
8.2.30.0000.00918.43
8.2.20.0040.00417.96
8.2.10.0040.00418.30
8.2.00.0080.00018.04
8.1.280.0110.00725.92
8.1.270.0030.00524.10
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0060.00322.30
8.1.230.0110.00019.47
8.1.220.0030.00517.80
8.1.210.0040.00418.77
8.1.200.0070.00317.47
8.1.190.0030.00617.48
8.1.180.0000.00918.10
8.1.170.0060.00318.95
8.1.160.0080.00022.14
8.1.150.0070.00018.92
8.1.140.0000.00717.82
8.1.130.0050.00218.08
8.1.120.0040.00417.70
8.1.110.0000.00717.66
8.1.100.0000.00817.67
8.1.90.0040.00417.58
8.1.80.0000.00817.58
8.1.70.0030.00317.60
8.1.60.0030.00617.83
8.1.50.0050.00317.75
8.1.40.0080.00017.79
8.1.30.0000.00817.91
8.1.20.0020.00517.71
8.1.10.0000.00817.82
8.1.00.0000.01017.80
8.0.300.0070.00018.77
8.0.290.0000.00717.38
8.0.280.0040.00418.60
8.0.270.0070.00017.46
8.0.260.0030.00317.52
8.0.250.0030.00317.21
8.0.240.0050.00317.14
8.0.230.0000.00817.20
8.0.220.0020.00517.12
8.0.210.0070.00017.12
8.0.200.0030.00317.20
8.0.190.0060.00317.27
8.0.180.0050.00317.12
8.0.170.0060.00317.16
8.0.160.0050.00217.13
8.0.150.0000.00717.01
8.0.140.0030.00517.11
8.0.130.0030.00313.71
8.0.120.0040.00417.14
8.0.110.0070.00017.13
8.0.100.0000.00717.02
8.0.90.0040.00417.25
8.0.80.0070.01317.23
8.0.70.0030.00517.14
8.0.60.0000.00717.07
8.0.50.0040.00417.06
8.0.30.0110.00917.33
8.0.20.0110.00817.40
8.0.10.0050.00317.29
8.0.00.0100.00717.09
7.4.330.0000.00615.00
7.4.320.0000.00716.63
7.4.300.0000.00616.74
7.4.290.0070.00016.76
7.4.280.0000.00716.71
7.4.270.0040.00416.76
7.4.260.0000.00716.65
7.4.250.0030.00516.64
7.4.240.0040.00416.72
7.4.230.0050.00216.63
7.4.220.0090.00916.82
7.4.210.0050.01116.88
7.4.200.0040.00416.79
7.4.190.0030.00316.87
7.4.160.0140.00416.78
7.4.150.0070.01017.40
7.4.140.0070.01717.86
7.4.130.0040.01216.71
7.4.120.0030.01316.87
7.4.110.0090.00916.71
7.4.100.0150.00916.75
7.4.90.0270.01016.86
7.4.80.0060.01219.39
7.4.70.0080.00816.88
7.4.60.0160.00016.84
7.4.50.0030.00316.72
7.4.40.0000.01616.65
7.4.30.0140.00316.64
7.4.10.0110.00815.25
7.4.00.0100.00814.96
7.3.330.0030.00313.39
7.3.320.0030.00513.62
7.3.310.0040.00416.69
7.3.300.0070.00016.48
7.3.290.0070.01316.73
7.3.280.0050.01116.65
7.3.270.0090.01217.40
7.3.260.0140.01116.69
7.3.250.0070.01216.61
7.3.240.0090.00616.61
7.3.230.0130.00916.54
7.3.210.0070.01116.68
7.3.200.0110.01119.39
7.3.190.0090.01316.76
7.3.180.0100.00716.78
7.3.170.0040.01416.52
7.3.160.0040.01316.92
7.3.130.0070.01015.04
7.3.120.0080.01015.02
7.3.110.0090.01015.00
7.3.100.0000.01514.98
7.3.90.0040.01114.97
7.3.80.0080.00815.18
7.3.70.0100.00314.96
7.3.60.0060.00314.72
7.3.50.0110.00315.12
7.3.40.0040.00814.96
7.3.30.0070.00715.01
7.3.20.0060.00616.60
7.3.10.0070.01216.68
7.3.00.0070.01016.80
7.2.330.0120.00616.84
7.2.320.0060.01217.02
7.2.310.0040.01416.90
7.2.300.0110.00517.05
7.2.290.0090.00817.02
7.2.260.0090.00915.38
7.2.250.0030.01515.43
7.2.240.0090.00615.43
7.2.230.0060.01415.39
7.2.220.0000.01615.44
7.2.210.0040.01315.51
7.2.200.0070.00715.01
7.2.190.0000.00914.92
7.2.180.0070.01114.99
7.2.170.0040.00715.00
7.2.160.0000.01415.22
7.2.150.0000.01216.88
7.2.140.0040.01117.13
7.2.130.0030.00716.97
7.2.120.0170.00216.77
7.2.110.0120.00517.00
7.2.100.0140.00816.88
7.2.90.0170.00616.81
7.2.80.0170.00716.89
7.2.70.0110.01317.03
7.2.60.0040.01417.09
7.2.50.0130.00516.95
7.2.40.0130.00516.97
7.2.30.0120.00716.89
7.2.20.0090.00716.96
7.2.10.0100.00516.79
7.2.00.0280.00717.89
7.1.330.0060.01215.60
7.1.320.0030.01015.56
7.1.310.0090.00616.05
7.1.300.0030.01215.56
7.1.290.0050.00515.73
7.1.280.0090.00315.94
7.1.270.0000.01315.96
7.1.260.0000.01416.01
7.1.250.0060.01115.66
7.1.240.0110.00415.95
7.1.230.0100.00615.92
7.1.220.0030.01415.88
7.1.210.0090.00916.12
7.1.200.0040.00815.90
7.1.190.0090.00915.58
7.1.180.0040.00815.57
7.1.170.0060.01015.70
7.1.160.0100.00616.10
7.1.150.0060.00615.95
7.1.140.0070.00716.00
7.1.130.0030.00616.02
7.1.120.0060.00915.79
7.1.110.0060.00316.11
7.1.100.0020.01117.18
7.1.90.0030.01315.76
7.1.80.0070.00715.61
7.1.70.0020.00716.76
7.1.60.0100.00817.48
7.1.50.0030.01316.45
7.1.40.0100.00415.83
7.1.30.0070.01115.89
7.1.20.0040.01115.97
7.1.10.0040.00415.77
7.1.00.0030.04319.24
7.0.330.0060.00315.44
7.0.320.0090.00615.36
7.0.310.0110.00415.60
7.0.300.0060.00615.29
7.0.290.0030.00615.44
7.0.280.0060.00315.50
7.0.270.0030.01015.58
7.0.260.0060.00615.54
7.0.250.0040.00815.63
7.0.240.0030.00615.48
7.0.230.0100.00715.62
7.0.220.0020.01315.62
7.0.210.0070.00315.29
7.0.200.0040.00516.13
7.0.190.0040.00815.27
7.0.180.0080.00815.37
7.0.170.0030.00615.63
7.0.160.0030.01415.69
7.0.150.0060.00615.29
7.0.140.0070.03718.82
7.0.130.0090.00315.61
7.0.120.0040.01115.31
7.0.110.0000.01015.47
7.0.100.0070.00715.73
7.0.90.0060.00615.54
7.0.80.0080.00515.57
7.0.70.0100.00015.26
7.0.60.0070.04317.80
7.0.50.0050.05016.94
7.0.40.0030.02516.94
7.0.30.0180.04317.07
7.0.20.0180.02617.00
7.0.10.0080.02816.88
7.0.00.0060.03016.95
5.6.400.0030.00614.44
5.6.390.0040.01114.52
5.6.380.0060.00914.57
5.6.370.0070.01114.48
5.6.360.0070.00714.26
5.6.350.0030.01014.68
5.6.340.0070.00714.38
5.6.330.0040.01114.12
5.6.320.0040.00414.25
5.6.310.0070.00714.61
5.6.300.0100.00014.01
5.6.290.0070.00714.15
5.6.280.0050.03917.92
5.6.270.0040.00414.52
5.6.260.0040.01114.56
5.6.250.0030.00714.33
5.6.240.0000.01414.23
5.6.230.0040.01214.41
5.6.220.0050.00514.11
5.6.210.0060.03917.55
5.6.200.0080.04216.45
5.6.190.0030.03317.61
5.6.180.0130.03117.72
5.6.170.0170.04417.51
5.6.160.0040.02917.66
5.6.150.0120.03816.33
5.6.140.0030.02816.40
5.6.130.0110.04316.44
5.6.120.0020.02617.92
5.6.110.0080.03717.79
5.6.100.0080.04717.71
5.6.90.0070.03517.72
5.6.80.0130.03517.43
5.6.70.0030.00914.03
5.6.60.0050.00514.15
5.6.50.0040.00714.19
5.6.40.0070.00714.54
5.6.30.0070.01114.42
5.6.20.0030.01214.27
5.6.10.0000.01614.24
5.6.00.0040.01114.22
5.5.380.0050.00514.34
5.5.370.0120.00314.46
5.5.360.0040.00414.61
5.5.350.2180.02617.52
5.5.340.0040.03116.23
5.5.330.0050.02117.51
5.5.320.0180.02517.51
5.5.310.0200.03017.52
5.5.300.0050.04716.30
5.5.290.0050.03616.29
5.5.280.0080.04317.76
5.5.270.0110.04417.72
5.5.260.0050.03717.56
5.5.250.0050.02517.39
5.5.240.0030.02317.23
5.5.230.0030.01414.24
5.5.220.0000.01514.48
5.5.210.0030.00614.06
5.5.200.0100.00014.30
5.5.190.0030.01414.20
5.5.180.0030.00614.30
5.5.170.0030.00914.38
5.5.160.0050.00514.41
5.5.150.0110.00414.18
5.5.140.0000.01314.41
5.5.130.0070.00713.90
5.5.120.0040.00414.45
5.5.110.0040.00414.48
5.5.100.0040.01114.14
5.5.90.0030.01014.28
5.5.80.0000.01414.34
5.5.70.0000.01314.30
5.5.60.0030.01014.21
5.5.50.0100.00313.92
5.5.40.0000.00814.10
5.5.30.0090.00914.40
5.5.20.0040.00814.20
5.5.10.0070.01014.26
5.5.00.0060.00914.36
5.4.450.0280.02515.38
5.4.440.0050.02815.50
5.4.430.0110.02715.46
5.4.420.0030.03015.42
5.4.410.0180.02615.37
5.4.400.0320.01715.27
5.4.390.0220.02715.14
5.4.380.0140.02715.04
5.4.370.0050.03215.00
5.4.360.0170.03415.11
5.4.350.0070.03314.98
5.4.340.0100.02914.94
5.4.330.0080.00411.30
5.4.320.0020.02411.98
5.4.310.0030.02711.98
5.4.300.0060.02211.98
5.4.290.0070.02111.98
5.4.280.0070.02111.93
5.4.270.0060.02111.93
5.4.260.0090.02011.93
5.4.250.0050.02111.93
5.4.240.0030.02611.93
5.4.230.0070.02111.92
5.4.220.0040.02211.93
5.4.210.0070.02111.93
5.4.200.0040.02511.92
5.4.190.0040.02211.92
5.4.180.0070.02111.92
5.4.170.0040.02611.93
5.4.160.0050.02411.93
5.4.150.0080.01911.93
5.4.140.0040.02711.77
5.4.130.0070.02611.77
5.4.120.0050.02711.74
5.4.110.0070.02711.74
5.4.100.0040.02911.74
5.4.90.0050.03111.74
5.4.80.0120.03711.74
5.4.70.0120.03011.74
5.4.60.0040.03011.74
5.4.50.0070.02811.74
5.4.40.0020.02411.73
5.4.30.0020.02811.73
5.4.20.0050.02911.73
5.4.10.0080.02711.73
5.4.00.0080.02411.47
5.3.290.0050.02412.11
5.3.280.0070.02712.08
5.3.270.0020.02712.08
5.3.260.0060.02112.09
5.3.250.0040.02912.09
5.3.240.0070.02812.09
5.3.230.0090.02612.08
5.3.220.0080.02712.07
5.3.210.0050.02412.07
5.3.200.0020.02512.06
5.3.190.0040.02312.07
5.3.180.0070.02212.07
5.3.170.0060.01912.06
5.3.160.0070.02012.06
5.3.150.0070.01912.06
5.3.140.0040.02312.06
5.3.130.0080.02112.06
5.3.120.0050.02112.06
5.3.110.0020.02412.05
5.3.100.0020.02411.80
5.3.90.0070.01911.79
5.3.80.0060.02011.79
5.3.70.0060.02211.78
5.3.60.0060.02111.78
5.3.50.0080.01811.75
5.3.40.0060.02111.75
5.3.30.0020.02311.73
5.3.20.0040.02311.62
5.3.10.0070.01911.60
5.3.00.0040.02311.60
5.2.170.0040.0319.42
5.2.160.0060.0319.41
5.2.150.0070.0299.41
5.2.140.0050.0379.41
5.2.130.0110.0419.38
5.2.120.0060.0319.38
5.2.110.0070.0279.38
5.2.100.0040.0299.38
5.2.90.0050.0309.38
5.2.80.0050.0429.37
5.2.70.0040.0439.37
5.2.60.0050.0369.32
5.2.50.0030.0399.29
5.2.40.0040.0319.27
5.2.30.0050.0329.24
5.2.20.0040.0329.23
5.2.10.0030.0339.13
5.2.00.0100.0268.99
5.1.60.0060.0238.28
5.1.50.0080.0228.27
5.1.40.0050.0238.25
5.1.30.0060.0248.61
5.1.20.0050.0278.63
5.1.10.0090.0228.35
5.1.00.0070.0278.35
5.0.50.0080.0246.84
5.0.40.0090.0206.70
5.0.30.0070.0286.52
5.0.20.0040.0236.48
5.0.10.0040.0226.46
5.0.00.0050.0306.45
4.4.90.0030.0204.78
4.4.80.0100.0134.75
4.4.70.0040.0174.75
4.4.60.0040.0184.75
4.4.50.0060.0134.77
4.4.40.0040.0254.71
4.4.30.0020.0184.75
4.4.20.0040.0204.84
4.4.10.0020.0244.85
4.4.00.0050.0344.76
4.3.110.0050.0224.67
4.3.100.0060.0214.66
4.3.90.0030.0214.63
4.3.80.0040.0304.58
4.3.70.0030.0174.63
4.3.60.0040.0154.63
4.3.50.0030.0164.63
4.3.40.0050.0274.54
4.3.30.0010.0223.30
4.3.20.0030.0153.28
4.3.10.0020.0153.24
4.3.00.0070.01713.84

preferences:
52.83 ms | 401 KiB | 5 Q