3v4l.org

run code in 300+ PHP versions simultaneously
<?php $body = <<<HTML <body class="old_attr"> <div>(content)</div> </body> HTML; $new_class = "new_class_attr"; $body = preg_replace('~<body[^>]*class *= *["\']\K~', "$new_class ", $body, 1, $count); if (!$count) { $body = preg_replace('~<body\K~', " class=\"$new_class\"", $body, 1); } echo $body;

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.0080.01216.97
8.3.50.0170.00016.52
8.3.40.0110.00719.23
8.3.30.0040.01119.09
8.3.20.0000.00821.10
8.3.10.0040.00721.76
8.3.00.0050.00521.74
8.2.180.0070.00716.88
8.2.170.0180.00422.96
8.2.160.0040.01120.47
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0070.00021.16
8.2.110.0060.00322.37
8.2.100.0040.00818.16
8.2.90.0000.00819.38
8.2.80.0040.00417.97
8.2.70.0000.00817.93
8.2.60.0000.00818.22
8.2.50.0030.00518.10
8.2.40.0000.00919.66
8.2.30.0040.00419.38
8.2.20.0060.00318.15
8.2.10.0030.00618.29
8.2.00.0000.00819.48
8.1.280.0150.00425.92
8.1.270.0000.00920.68
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0090.00019.25
8.1.230.0080.00320.89
8.1.220.0000.00917.79
8.1.210.0030.00518.91
8.1.200.0080.00017.48
8.1.190.0060.00317.48
8.1.180.0000.01218.10
8.1.170.0040.00418.46
8.1.160.0050.00219.02
8.1.150.0000.00818.98
8.1.140.0070.00022.11
8.1.130.0040.00417.68
8.1.120.0030.00317.60
8.1.110.0080.00017.62
8.1.100.0000.00717.53
8.1.90.0000.00717.61
8.1.80.0080.00017.67
8.1.70.0000.00717.53
8.1.60.0060.00317.66
8.1.50.0040.00417.58
8.1.40.0000.00817.68
8.1.30.0040.00417.69
8.1.20.0090.00017.83
8.1.10.0060.00317.70
8.1.00.0040.00417.60
8.0.300.0040.00419.98
8.0.290.0040.00417.13
8.0.280.0050.00218.48
8.0.270.0030.00317.11
8.0.260.0040.00417.11
8.0.250.0030.00517.29
8.0.240.0030.00317.18
8.0.230.0000.00717.20
8.0.220.0000.00717.14
8.0.210.0000.00717.23
8.0.200.0030.00317.25
8.0.190.0040.00417.25
8.0.180.0030.00517.23
8.0.170.0000.00917.19
8.0.160.0040.00417.20
8.0.150.0030.00717.13
8.0.140.0040.00417.14
8.0.130.0050.00013.66
8.0.120.0050.00317.31
8.0.110.0040.00417.29
8.0.100.0050.00217.14
8.0.90.0070.00017.13
8.0.80.0100.00617.22
8.0.70.0040.00417.30
8.0.60.0040.00417.14
8.0.50.0000.00717.24
8.0.30.0130.00717.42
8.0.20.0090.00917.48
8.0.10.0000.00717.26
8.0.00.0070.01016.88
7.4.330.0030.00316.72
7.4.320.0000.00616.79
7.4.300.0030.00316.71
7.4.290.0030.00316.89
7.4.280.0000.00816.75
7.4.270.0030.00316.90
7.4.260.0040.00416.75
7.4.250.0040.00416.85
7.4.240.0070.00016.91
7.4.230.0030.00316.93
7.4.220.0060.00316.54
7.4.210.0030.01016.86
7.4.200.0000.00716.63
7.4.160.0090.00916.77
7.4.140.0130.00717.86
7.4.130.0120.00616.72
7.4.120.0100.00816.78
7.4.110.0150.00916.97
7.4.100.0000.01916.75
7.4.90.0110.00616.96
7.4.80.0120.00619.39
7.4.70.0000.01816.57
7.4.60.0030.01316.79
7.4.50.0050.00816.55
7.4.40.0100.00616.83
7.4.00.0110.00415.13
7.3.330.0030.00313.39
7.3.320.0060.00013.38
7.3.310.0040.00416.48
7.3.300.0000.00616.54
7.3.290.0000.00616.50
7.3.280.0070.00916.49
7.3.260.0120.00716.77
7.3.240.0060.01316.69
7.3.230.0200.00016.76
7.3.210.0120.00916.73
7.3.200.0070.01016.66
7.3.190.0090.01316.60
7.3.180.0090.00616.48
7.3.170.0070.01016.63
7.3.160.0120.00316.80
7.3.10.0170.00716.49
7.3.00.0130.00616.48
7.2.330.0110.01116.82
7.2.320.0030.01416.86
7.2.310.0120.01216.84
7.2.300.0100.00616.85
7.2.290.0100.00716.67
7.2.130.0120.00516.61
7.2.120.0920.00515.75
7.2.110.0390.00915.84
7.2.100.0410.00415.78
7.2.90.0470.01415.72
7.2.80.0340.00615.61
7.2.70.0470.01016.17
7.2.60.0420.00916.08
7.2.50.0360.00616.02
7.2.40.0450.00815.79
7.2.30.0710.00615.82
7.2.20.0540.00315.73
7.2.10.0400.00516.07
7.2.00.0430.00815.98
7.1.250.0130.00515.70
7.1.240.0860.01014.08
7.1.230.0740.01414.14
7.1.220.0770.00714.08
7.1.210.0890.01014.20
7.1.200.0560.00614.20
7.1.190.0850.00313.96
7.1.180.0810.00314.11
7.1.170.0800.00713.89
7.1.160.0810.01114.06
7.1.150.0780.01214.16
7.1.140.0900.00314.12
7.1.130.0680.01314.14
7.1.120.0830.00314.17
7.1.110.0730.01014.29
7.1.100.0530.00714.07
7.1.90.0860.00314.23
7.1.80.0750.01113.78
7.1.70.0710.01013.85
7.1.60.0810.01614.01
7.1.50.0860.00714.03
7.1.40.0690.00713.96
7.1.30.1010.01014.01
7.1.20.0840.00314.17
7.1.10.0740.00913.79
7.1.00.0770.00413.93
5.6.380.0090.00914.43

preferences:
78.27 ms | 401 KiB | 5 Q