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.0120.00316.63
8.3.50.0110.00316.34
8.3.40.0110.00418.71
8.3.30.0070.00718.98
8.3.20.0000.00820.19
8.3.10.0080.00023.46
8.3.00.0050.00319.38
8.2.180.0090.00918.66
8.2.170.0040.01122.96
8.2.160.0100.00720.48
8.2.150.0040.00424.18
8.2.140.0050.00224.66
8.2.130.0000.00821.16
8.2.120.0080.00026.35
8.2.110.0030.00722.33
8.2.100.0080.00318.03
8.2.90.0000.00819.21
8.2.80.0000.00818.00
8.2.70.0080.00017.88
8.2.60.0000.00817.80
8.2.50.0040.00418.16
8.2.40.0040.00420.24
8.2.30.0000.00921.21
8.2.20.0040.00418.02
8.2.10.0000.00718.14
8.2.00.0000.01018.09
8.1.280.0100.00725.92
8.1.270.0040.00423.82
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00620.81
8.1.230.0030.00717.70
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0030.00717.47
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0040.00420.48
8.1.160.0040.00419.09
8.1.150.0000.00920.61
8.1.140.0000.00819.60
8.1.130.0060.00318.91
8.1.120.0040.00417.69
8.1.110.0000.00717.58
8.1.100.0070.00017.59
8.1.90.0000.01017.50
8.1.80.0040.00417.58
8.1.70.0090.00017.62
8.1.60.0040.00417.74
8.1.50.0080.00017.69
8.1.40.0030.00517.56
8.1.30.0040.00417.79
8.1.20.0000.01417.87
8.1.10.0040.00417.71
8.1.00.0040.00417.68
8.0.300.0040.00418.77
8.0.290.0000.00816.88
8.0.280.0030.00518.42
8.0.270.0000.00717.16
8.0.260.0000.00816.88
8.0.250.0030.00317.07
8.0.240.0040.00417.16
8.0.230.0040.00416.99
8.0.220.0030.00516.93
8.0.210.0040.00417.13
8.0.200.0000.00817.09
8.0.190.0050.00516.99
8.0.180.0000.00817.09
8.0.170.0030.00517.13
8.0.160.0040.00417.06
8.0.150.0030.00317.00
8.0.140.0040.00417.01
8.0.130.0050.00013.41
8.0.120.0000.00816.88
8.0.110.0050.00316.84
8.0.100.0000.00817.02
8.0.90.0040.00416.87
8.0.80.0120.00916.96
8.0.70.0040.00416.93
8.0.60.0040.00417.09
8.0.50.0040.00417.08
8.0.30.0130.00517.11
8.0.20.0100.01017.50
8.0.10.0000.00717.23
8.0.00.0040.01416.70
7.4.330.0000.00615.55
7.4.320.0000.00616.86
7.4.300.0000.00616.63
7.4.290.0000.01216.86
7.4.280.0070.00016.79
7.4.270.0030.00316.73
7.4.260.0000.00613.45
7.4.250.0070.00016.77
7.4.240.0030.00516.67
7.4.230.0030.00316.85
7.4.220.0110.00416.81
7.4.210.0040.01116.61
7.4.200.0030.00316.63
7.4.160.0090.00816.66
7.4.150.0180.00017.40
7.4.140.0070.00917.86
7.4.130.0130.00316.82
7.4.120.0120.00816.72
7.4.110.0100.01016.46
7.4.100.0070.01016.61
7.4.90.0170.00016.68
7.4.80.0130.00619.39
7.4.70.0030.01516.79
7.4.60.0100.00716.75
7.4.50.0030.01316.73
7.4.40.0120.00316.54
7.4.30.0080.00816.64
7.4.00.0080.00815.04
7.3.330.0060.00013.46
7.3.320.0000.00513.41
7.3.310.0070.00016.54
7.3.300.0000.00716.46
7.3.290.0030.01116.41
7.3.280.0100.00716.45
7.3.270.0040.01517.40
7.3.260.0070.01016.49
7.3.250.0120.00616.50
7.3.240.0130.00816.53
7.3.230.0090.00916.50
7.3.210.0070.01216.47
7.3.200.0060.00916.63
7.3.190.0110.00516.71
7.3.180.0080.00816.80
7.3.170.0060.01016.44
7.3.160.0070.01016.59
7.3.120.0060.01015.15
7.3.110.0040.01414.76
7.3.100.0090.00514.95
7.3.90.0020.01115.09
7.3.80.0010.00814.85
7.3.70.0080.00414.78
7.3.60.0050.00815.06
7.3.50.0040.00614.81
7.3.40.0040.01014.81
7.3.30.0050.00414.83
7.3.20.0050.00916.94
7.3.10.0050.01116.82
7.3.00.0050.00616.94
7.2.330.0030.01416.90
7.2.320.0140.00316.65
7.2.310.0170.00016.69
7.2.300.0060.01616.62
7.2.290.0070.01016.82
7.2.250.0100.01014.92
7.2.240.0070.01215.16
7.2.230.0090.00615.31
7.2.220.0020.01615.32
7.2.210.0060.00615.15
7.2.200.0020.01015.23
7.2.190.0050.01115.33
7.2.180.0050.01115.13
7.2.170.0090.00814.95
7.2.160.0000.01515.28
7.2.150.0000.01417.19
7.2.140.0060.00916.79
7.2.130.0030.01016.91
7.2.120.0040.00416.91
7.2.110.0040.01116.74
7.2.100.0060.00917.07
7.2.90.0080.00517.11
7.2.80.0070.00717.09
7.2.70.0070.00317.20
7.2.60.0040.00917.07
7.2.50.0060.00617.05
7.2.40.0030.01017.16
7.2.30.0030.00617.05
7.2.20.0040.00716.94
7.2.10.0000.01517.12
7.2.00.0050.01018.34
7.1.330.0050.01016.08
7.1.320.0030.01215.83
7.1.310.0060.00915.79
7.1.300.0030.01215.86
7.1.290.0070.00416.05
7.1.280.0070.00715.94
7.1.270.0060.00815.80
7.1.260.0090.00516.03
7.1.250.0030.00516.00
7.1.200.0120.00016.03
7.1.100.0070.00718.23
7.1.70.0030.00917.16
7.1.60.0230.00335.25
7.1.50.0140.01234.70
7.1.40.0150.00934.58
7.1.30.0110.01534.79
7.1.20.0150.01135.00
7.1.10.0050.00816.69
7.1.00.0060.00616.86
7.0.200.0040.00816.77
7.0.190.0080.00416.98
7.0.180.0000.01116.39
7.0.170.0030.00916.28
7.0.160.0060.00616.21
7.0.150.0030.00816.26
7.0.140.0030.01016.33
7.0.130.0090.00316.80
7.0.120.0060.00616.80
7.0.110.0040.00816.38
7.0.100.0060.00616.55
7.0.90.0090.00316.50
7.0.80.0030.00916.43
7.0.70.0000.01216.37
7.0.60.0040.00816.32
7.0.50.0130.01016.50
7.0.40.0000.01116.53
7.0.30.0080.00516.48
7.0.20.0000.01216.48
7.0.10.0000.01216.59
7.0.00.0100.00716.60

preferences:
41.98 ms | 401 KiB | 5 Q