3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highlight($text, $words) { preg_match_all ( '~[\w\']+~', $words, $m ); if (! $m) return $text; $re = '~\\b(' . implode ( '|', $m [0] ) . ')\\b~i'; return preg_replace ( $re, '<em>$0</em>', $text ); } $text = "this is Mechanic's test"; $word = "Mechanic's"; echo highlight($text,$word); $text = 'this is Mechanic"s test'; $word = 'Mechanic"s'; echo "\n".highlight($text,$word); $text = 'this is Mechanics test'; $word = 'mech'; echo "\n".highlight($text,$word); // echo "\n".str_replace($word,"<em>$word</em>",$text) ;

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.0140.00416.63
8.3.50.0160.00316.44
8.3.40.0060.00918.67
8.3.30.0070.00719.02
8.3.20.0040.00420.29
8.3.10.0090.00021.73
8.3.00.0040.00419.38
8.2.180.0110.00718.30
8.2.170.0110.00422.96
8.2.160.0110.00420.47
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0050.00226.16
8.2.120.0040.00420.89
8.2.110.0070.00319.38
8.2.100.0090.00318.22
8.2.90.0050.00319.34
8.2.80.0000.00817.97
8.2.70.0060.00617.75
8.2.60.0050.00318.05
8.2.50.0080.00018.10
8.2.40.0000.00922.30
8.2.30.0080.00019.22
8.2.20.0040.00418.03
8.2.10.0040.00418.16
8.2.00.0080.00018.02
8.1.280.0080.00825.92
8.1.270.0030.00623.80
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0000.01022.07
8.1.230.0060.00617.47
8.1.220.0040.00417.79
8.1.210.0060.00318.77
8.1.200.0060.00317.36
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0060.00318.71
8.1.160.0000.00818.98
8.1.150.0030.00620.78
8.1.140.0000.00719.61
8.1.130.0040.00418.92
8.1.120.0040.00417.53
8.1.110.0040.00417.50
8.1.100.0040.00417.60
8.1.90.0060.00317.57
8.1.80.0000.00817.50
8.1.70.0000.00817.64
8.1.60.0040.00417.73
8.1.50.0040.00417.66
8.1.40.0030.00517.53
8.1.30.0040.00417.66
8.1.20.0040.00717.83
8.1.10.0080.00017.75
8.1.00.0050.00217.66
8.0.300.0050.00218.77
8.0.290.0040.00416.75
8.0.280.0000.00718.41
8.0.270.0040.00417.29
8.0.260.0030.00516.84
8.0.250.0070.00017.07
8.0.240.0000.00817.11
8.0.230.0040.00417.17
8.0.220.0000.00617.02
8.0.210.0000.00716.96
8.0.200.0000.00717.14
8.0.190.0030.00917.02
8.0.180.0000.00916.99
8.0.170.0070.00016.90
8.0.160.0000.00817.08
8.0.150.0030.00317.02
8.0.140.0070.00417.03
8.0.130.0050.00013.43
8.0.120.0030.00516.99
8.0.110.0000.00716.89
8.0.100.0000.00717.11
8.0.90.0040.00416.85
8.0.80.0090.00617.05
8.0.70.0000.00716.99
8.0.60.0000.00817.04
8.0.50.0070.00017.11
8.0.30.0110.00917.20
8.0.20.0090.01017.44
8.0.10.0050.00317.04
8.0.00.0130.00416.79
7.4.330.0000.00515.55
7.4.320.0000.00816.77
7.4.300.0000.00616.86
7.4.290.0030.00816.83
7.4.280.0030.00616.66
7.4.270.0070.00016.74
7.4.260.0000.00613.43
7.4.250.0000.00816.83
7.4.240.0000.00716.83
7.4.230.0040.00416.84
7.4.220.0100.00616.76
7.4.210.0110.00616.84
7.4.200.0030.00316.72
7.4.160.0080.01116.65
7.4.150.0090.01517.40
7.4.140.0080.01017.86
7.4.130.0140.01016.71
7.4.120.0080.01116.80
7.4.110.0140.00716.78
7.4.100.0060.01016.82
7.4.90.0070.01016.68
7.4.80.0070.01019.39
7.4.70.0070.01016.75
7.4.60.0030.01316.79
7.4.50.0060.00916.68
7.4.40.0140.00316.70
7.4.30.0080.00816.83
7.4.00.0060.01015.11
7.3.330.0070.00013.42
7.3.320.0030.00313.22
7.3.310.0000.00716.36
7.3.300.0000.00716.46
7.3.290.0000.00716.40
7.3.280.0070.00916.45
7.3.270.0160.00417.40
7.3.260.0110.00616.63
7.3.250.0120.00616.54
7.3.240.0070.01216.76
7.3.230.0100.01016.48
7.3.210.0060.01716.36
7.3.200.0060.01216.43
7.3.190.0070.01016.46
7.3.180.0070.01016.45
7.3.170.0060.00916.66
7.3.160.0120.00616.63
7.3.120.0090.00914.96
7.3.110.0100.00714.94
7.3.100.0070.01115.22
7.3.90.0090.00914.99
7.3.80.0030.01214.85
7.3.70.0060.00314.64
7.3.60.0060.00914.69
7.3.50.0030.00914.82
7.3.40.0130.00314.62
7.3.30.0040.01114.98
7.3.20.0080.00416.90
7.3.10.0040.01116.50
7.3.00.0030.01316.96
7.2.330.0030.01916.70
7.2.320.0070.01016.73
7.2.310.0070.01016.88
7.2.300.0070.01016.89
7.2.290.0130.00416.71
7.2.250.0130.00715.32
7.2.240.0080.00815.37
7.2.230.0030.00915.29
7.2.220.0130.00715.25
7.2.210.0100.01015.40
7.2.200.0100.00015.14
7.2.190.0030.01315.32
7.2.180.0090.00615.30
7.2.170.0000.01315.34
7.2.60.0110.00417.28
7.1.330.0040.01115.84
7.1.320.0130.00316.02
7.1.310.0040.01515.70
7.1.300.0030.00715.87
7.1.290.0040.00415.87
7.1.280.0060.00315.75
7.1.270.0080.00815.94
7.1.260.0000.01115.95
7.1.200.0040.00916.21
7.1.70.0190.00415.48
7.1.60.0380.01033.45
7.1.50.0290.01033.22
7.1.40.0160.01634.56
7.1.30.0250.01534.93
7.1.20.0170.01034.83
7.1.10.0050.00816.71
7.1.00.0140.00815.05
7.0.200.0140.01115.14
7.0.190.0140.01115.16
7.0.180.0060.00916.37
7.0.170.0220.00316.46
7.0.160.0030.01216.54
7.0.150.0060.00616.05
7.0.140.0110.00316.34
7.0.130.0130.00916.81
7.0.120.0030.00916.73
7.0.110.0190.00414.65
7.0.100.0030.01116.52
7.0.90.0060.00616.48
7.0.80.0100.01014.80
7.0.70.0080.01214.66
7.0.60.0030.01016.17
7.0.50.0110.01114.59
7.0.40.0120.01216.82
7.0.30.0060.00616.45
7.0.20.0140.00714.89
7.0.10.0080.00616.61
7.0.00.0080.00416.46

preferences:
51.52 ms | 400 KiB | 5 Q