3v4l.org

run code in 300+ PHP versions simultaneously
<?php function walkDOM($node) { if($node->nodeName=="pre" || $node->nodeName=="code") { return; } elseif($node->nodeName=="img") { $node->attributes->getNamedItem("src")->nodeValue=str_replace('desktop-img','mobile-img',$node->attributes->getNamedItem("src")->nodeValue); } elseif($node->hasChildNodes()) { foreach(range(0,$node->childNodes->length-1) as $idx) { walkDOM($node->childNodes->item($idx)); } } } function changeImagePath($html) { $dom=new DOMDocument; $dom->loadHTML($html); $root=$dom->documentElement; walkDOM($root); return $dom->saveHTML(); } echo changeImagePath(<<<HTML <div class="wrapper"> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> <pre> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> </pre> <code> <img src="img/demo/desktop-img/sample1.jpg" width="200" height="200" alt="image"> <img src="img/demo/desktop-img/sample2.jpg" width="200" height="200" alt="image"> </code> </div> HTML );

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.0140.00716.74
8.3.60.0040.01116.75
8.3.50.0090.01216.65
8.3.40.0140.00019.17
8.3.30.0120.00418.94
8.3.20.0150.00419.20
8.3.10.0090.00020.94
8.3.00.0040.00418.00
8.2.180.0180.00316.63
8.2.170.0090.00622.96
8.2.160.0090.00622.36
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00418.03
8.2.110.0030.00621.23
8.2.100.0110.00017.97
8.2.90.0040.00719.36
8.2.80.0050.00318.30
8.2.70.0040.00417.75
8.2.60.0090.00017.93
8.2.50.0000.00818.07
8.2.40.0030.00618.41
8.2.30.0020.00518.39
8.2.20.0040.00417.78
8.2.10.0070.00317.92
8.2.00.0040.00417.99
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0000.00921.05
8.1.230.0070.00321.11
8.1.220.0000.00817.79
8.1.210.0030.00619.12
8.1.200.0080.00417.60
8.1.190.0000.00817.78
8.1.180.0030.00518.10
8.1.170.0040.00418.93
8.1.160.0000.00719.11
8.1.150.0000.00818.94
8.1.140.0050.00217.62
8.1.130.0000.00718.08
8.1.120.0040.00417.63
8.1.110.0000.00817.71
8.1.100.0040.00417.63
8.1.90.0000.00717.62
8.1.80.0020.00517.77
8.1.70.0000.00817.76
8.1.60.0070.00017.75
8.1.50.0080.00017.76
8.1.40.0040.00417.78
8.1.30.0000.00717.83
8.1.20.0040.00417.83
8.1.10.0030.00517.76
8.1.00.0040.00417.81
8.0.300.0000.00720.01
8.0.290.0060.00317.00
8.0.280.0000.00818.66
8.0.270.0090.00017.41
8.0.260.0030.00317.02
8.0.250.0030.00717.24
8.0.240.0070.00417.24
8.0.230.0040.00417.18
8.0.220.0070.00017.16
8.0.210.0040.00417.11
8.0.200.0040.00417.30
8.0.190.0040.00417.25
8.0.180.0000.00717.23
8.0.170.0080.00017.11
8.0.160.0000.00717.28
8.0.150.0060.00317.07
8.0.140.0080.00217.07
8.0.130.0040.00413.60
8.0.120.0040.00417.20
8.0.110.0040.00417.10
8.0.100.0040.00417.24
8.0.90.0030.00516.89
8.0.80.0030.01317.08
8.0.70.0070.00017.22
8.0.60.0000.00717.17
8.0.50.0040.00417.30
8.0.30.0130.00617.32
8.0.20.0090.01017.38
8.0.10.0040.00417.13
8.0.00.0080.01117.16
7.4.330.0000.00513.25
7.4.320.0040.00416.84
7.4.300.0000.00716.91
7.4.290.0000.00716.92
7.4.280.0050.00516.91
7.4.270.0070.00016.80
7.4.260.0060.00013.54
7.4.250.0030.00516.66
7.4.240.0000.00716.85
7.4.230.0000.00816.83
7.4.220.0150.00016.77
7.4.210.0050.01016.71
7.4.200.0070.00016.77
7.4.190.0030.00317.05
7.4.160.0040.01216.87
7.4.150.0180.00617.08
7.4.140.0110.00816.81
7.4.130.0080.01016.69
7.4.120.0100.00816.90
7.4.110.0100.00716.66
7.4.100.0100.00716.65
7.4.90.0030.01516.82
7.4.80.0120.00616.59
7.4.70.0070.01016.87
7.4.60.0110.00616.54
7.4.50.0070.00016.66
7.4.40.0080.00516.70
7.4.30.0060.01116.72
7.4.10.0100.01015.15
7.4.00.0050.01215.06
7.3.330.0030.00313.43
7.3.320.0050.00013.47
7.3.310.0000.00716.50
7.3.300.0030.00316.45
7.3.290.0070.01016.54
7.3.280.0070.00916.51
7.3.270.0120.00616.66
7.3.260.0110.00616.68
7.3.250.0140.00816.70
7.3.240.0120.00916.68
7.3.230.0100.00616.83
7.3.210.0000.01816.67
7.3.200.0110.00719.39
7.3.190.0100.00716.65
7.3.180.0120.00316.57
7.3.170.0120.00916.69
7.3.160.0060.01316.54
7.3.130.0050.01315.18
7.3.120.0060.01015.01
7.3.110.0060.01314.85
7.3.100.0000.01514.87
7.3.90.0040.00415.04
7.3.80.0000.01514.73
7.3.70.0120.00314.70
7.3.60.0030.00914.89
7.3.50.0040.01114.85
7.3.40.0090.00614.73
7.3.30.0040.01115.00
7.3.20.0030.01016.52
7.3.10.0060.00916.80
7.3.00.0090.00616.49
7.2.330.0120.00616.80
7.2.320.0090.00917.10
7.2.310.0170.00817.07
7.2.300.0030.01316.67
7.2.290.0030.01316.86
7.2.260.0030.01415.41
7.2.250.0070.01415.30
7.2.240.0030.01115.43
7.2.230.0110.00415.44
7.2.220.0120.00615.20
7.2.210.0040.01115.23
7.2.200.0000.01515.30
7.2.190.0070.00715.10
7.2.180.0080.00815.00
7.2.170.0030.01315.05
7.2.160.0030.00615.25
7.2.150.0000.01417.26
7.2.140.0000.01617.05
7.2.130.0100.01017.21
7.2.120.0060.00917.16
7.2.110.0090.00617.00
7.2.100.0100.00717.16
7.2.90.0000.01817.07
7.2.80.0030.01316.94
7.2.70.0030.00816.96
7.2.60.0070.01017.00
7.2.50.0060.01016.98
7.2.40.0110.00717.02
7.2.30.0060.00617.15
7.2.20.0030.00817.09
7.2.10.0060.00617.08
7.2.00.0040.00817.13
7.1.330.0030.00515.80
7.1.320.0060.01015.71
7.1.310.0030.00915.84
7.1.300.0060.01015.76
7.1.290.0090.00615.64
7.1.280.0030.01015.91
7.1.270.0040.00715.63
7.1.260.0090.00015.95
7.1.250.0030.01216.10
7.1.240.0100.00716.07
7.1.230.0070.00715.78
7.1.220.0030.01015.68
7.1.210.0080.00815.92
7.1.200.0000.01115.99
7.1.190.0030.01315.65
7.1.180.0060.00915.88
7.1.170.0000.01115.95
7.1.160.0030.01415.73
7.1.150.0100.00315.92
7.1.140.0120.00416.05
7.1.130.0060.00315.80
7.1.120.0080.00015.77
7.1.110.0030.01315.94
7.1.100.0090.00616.03
7.1.90.0040.00715.65
7.1.80.0030.00615.70
7.1.70.0020.01016.73
7.1.60.0050.01217.54
7.1.50.0030.01516.36
7.1.40.0090.00015.99
7.1.30.0070.01015.98
7.1.20.0070.00415.98
7.1.10.0030.01015.90
7.1.00.0070.03719.05
7.0.330.0040.01115.49
7.0.320.0060.00315.49
7.0.310.0030.00915.50
7.0.300.0090.00615.50
7.0.290.0040.01215.23
7.0.280.0070.00715.45
7.0.270.0000.01415.24
7.0.260.0100.00315.61
7.0.250.0030.01315.62
7.0.240.0030.00615.39
7.0.230.0040.00715.34
7.0.220.0000.01515.62
7.0.210.0000.00815.38
7.0.200.0030.00916.16
7.0.190.0070.00715.31
7.0.180.0070.01015.45
7.0.170.0030.01015.71
7.0.160.0110.00415.51
7.0.150.0150.00015.41
7.0.140.0070.03818.65
7.0.130.0030.01315.37
7.0.120.0020.04418.83
7.0.110.0080.02917.86
7.0.100.0070.03217.89
7.0.90.0100.04317.73
7.0.80.0100.04517.93
7.0.70.0060.03217.69
7.0.60.0100.04117.80
7.0.50.0070.04617.80
7.0.40.0030.05016.63
7.0.30.0020.03116.81
7.0.20.0080.04316.76
7.0.10.0070.03716.77
7.0.00.0100.02016.70
5.6.400.0040.00414.14
5.6.390.0040.01114.13
5.6.380.0110.00014.48
5.6.370.0030.00914.42
5.6.360.0110.00714.72
5.6.350.0030.01014.54
5.6.340.0070.00714.45
5.6.330.0070.00714.68
5.6.320.0060.00914.39
5.6.310.0100.00614.57
5.6.300.0050.00514.73
5.6.290.0060.01014.46
5.6.280.0100.03817.73
5.6.270.0040.01514.49
5.6.260.0080.02817.70
5.6.250.0020.05117.74
5.6.240.0090.03017.63
5.6.230.0100.04017.55
5.6.220.0080.02517.58
5.6.210.0090.03717.63
5.6.200.0080.03017.50
5.6.190.0080.04817.63
5.6.180.0130.03817.52
5.6.170.0080.03817.48
5.6.160.0030.02817.66
5.6.150.0040.03717.56
5.6.140.0100.04017.55
5.6.130.0050.03317.57
5.6.120.0060.02517.65
5.6.110.0080.02217.60
5.6.100.0040.02417.52
5.6.90.0050.02317.43
5.6.80.0060.02317.18
5.6.70.0070.01817.42
5.6.60.0050.02617.20
5.6.50.0040.03517.26
5.6.40.0030.02717.13
5.6.30.0050.02317.24
5.6.20.0050.02317.29
5.6.10.0100.01817.22
5.6.00.0060.02617.13
5.5.380.0080.04517.32
5.5.370.0130.04017.41
5.5.360.0070.04917.36
5.5.350.0040.04317.40
5.5.340.0100.03817.53
5.5.330.0070.04517.73
5.5.320.0130.03717.47
5.5.310.0050.03117.79
5.5.300.0030.03017.55
5.5.290.0050.02417.80
5.5.280.0080.02317.69
5.5.270.0060.02317.50
5.5.260.0090.02217.77
5.5.250.0030.02917.61
5.5.240.0050.03017.34
5.5.230.0110.03817.29
5.5.220.0060.02317.43
5.5.210.0050.02517.42
5.5.200.0070.02217.21
5.5.190.0050.02517.23
5.5.180.0110.02717.43
5.5.170.0100.01014.14
5.5.160.0050.02317.34
5.5.150.0050.02017.34
5.5.140.0020.03717.32
5.5.130.0070.02217.40
5.5.120.0080.01817.37
5.5.110.0080.03217.17
5.5.100.0060.02517.40
5.5.90.0020.02517.42
5.5.80.0070.03017.39
5.5.70.0050.02117.22
5.5.60.0060.03417.21
5.5.50.0020.03117.25
5.5.40.0080.02017.28
5.5.30.0070.02317.10
5.5.20.0080.01717.26
5.5.10.0030.02117.34
5.5.00.0090.02017.16
5.4.450.0040.02515.32
5.4.440.0060.02215.44
5.4.430.0030.02215.60
5.4.420.0050.02315.36
5.4.410.0050.02315.32
5.4.400.0030.02015.14
5.4.390.0050.02215.11
5.4.380.0050.02315.02
5.4.370.0020.02415.15
5.4.360.0020.02515.29
5.4.350.0050.02215.00
5.4.340.0020.02515.10
5.4.330.0040.00710.95
5.4.320.0030.02615.04
5.4.310.0050.01815.26
5.4.300.0030.03515.26
5.4.290.0040.02515.31
5.4.280.0050.01814.99
5.4.270.0100.02315.28
5.4.260.0030.02115.26
5.4.250.0030.02215.15
5.4.240.0030.02315.10
5.4.230.0030.02415.07
5.4.220.0050.02215.06
5.4.210.0030.02315.34
5.4.200.0000.02714.93
5.4.190.0010.02415.31
5.4.180.0040.02115.30
5.4.170.0030.02315.20
5.4.160.0070.02115.14
5.4.150.0030.03715.16
5.4.140.0030.01913.69
5.4.130.0110.02113.71
5.4.120.0030.04013.83
5.4.110.0070.04213.82
5.4.100.0080.03613.91
5.4.90.0030.02413.92
5.4.80.0130.02513.94
5.4.70.0030.03713.85
5.4.60.0070.03513.75
5.4.50.0070.03513.91
5.4.40.0080.02113.85
5.4.30.0050.03813.99
5.4.20.0060.03513.81
5.4.10.0090.03613.85
5.4.00.0010.04113.51
5.3.290.0020.02212.70
5.3.280.0050.01812.64
5.3.270.0020.02512.80
5.3.260.0020.02712.72
5.3.250.0030.04212.76
5.3.240.0030.04412.69
5.3.230.0030.02612.78
5.3.220.0100.03512.58
5.3.210.0080.03512.61
5.3.200.0080.03712.61
5.3.190.0050.02012.65
5.3.180.0060.04212.63
5.3.170.0030.02512.80
5.3.160.0030.03212.73
5.3.150.0030.04312.70
5.3.140.0050.03512.60
5.3.130.0090.03812.68
5.3.120.0050.04212.62
5.3.110.0050.04112.69
5.3.100.0070.03812.32
5.3.90.0050.04012.42
5.3.80.0050.04212.36
5.3.70.0060.04212.23
5.3.60.0020.04212.40
5.3.50.0070.03712.34
5.3.40.0100.02012.36
5.3.30.0110.03212.48
5.3.20.0050.03712.27
5.3.10.0030.04111.98
5.3.00.0050.03812.12
5.2.170.0070.06011.87
5.2.160.0030.06011.87
5.2.150.0030.06711.87
5.2.140.0030.06311.87
5.2.130.0000.06711.87
5.2.120.0130.05311.87
5.2.110.0070.03011.87
5.2.100.0030.06011.87
5.2.90.0100.05711.87
5.2.80.0100.06311.87
5.2.70.0030.03711.87
5.2.60.0100.05011.87
5.2.50.0170.04711.87
5.2.40.0070.06011.87
5.2.30.0070.06011.87
5.2.20.0030.04011.87
5.2.10.0100.05711.87
5.2.00.0070.05711.87
5.1.60.0070.04711.87
5.1.50.0030.05311.87
5.1.40.0070.04011.87
5.1.30.0000.06011.87
5.1.20.0030.04711.87
5.1.10.0030.05011.87
5.1.00.0130.04311.87
5.0.50.0030.04711.87
5.0.40.0030.04711.87
5.0.30.0030.04311.87
5.0.20.0030.04011.87
5.0.10.0030.04311.87
5.0.00.0030.06711.87
4.4.90.0030.03311.87
4.4.80.0000.02711.87
4.4.70.0100.03011.87
4.4.60.0030.03311.87
4.4.50.0030.03011.87
4.4.40.0030.04711.87
4.4.30.0000.03711.87
4.4.20.0070.01011.87
4.4.10.0030.01711.87
4.4.00.0030.05311.87
4.3.110.0030.03011.87
4.3.100.0000.03311.87
4.3.90.0030.02311.87
4.3.80.0100.03011.87
4.3.70.0030.03311.87
4.3.60.0030.03711.87
4.3.50.0070.03011.87
4.3.40.0000.04011.87
4.3.30.0000.03711.87
4.3.20.0000.03311.87
4.3.10.0030.03311.87
4.3.00.0000.03711.87

preferences:
52.45 ms | 401 KiB | 5 Q