3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highlight($text, $words) { preg_match_all ( '~[a-zA-Z_\']*~', $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.70.0120.00318.31
8.3.60.0090.00616.88
8.3.50.0230.00717.37
8.3.40.0180.00319.01
8.3.30.0120.00318.79
8.3.20.0080.00021.93
8.3.10.0040.00423.74
8.3.00.0030.00519.38
8.2.180.0140.00418.66
8.2.170.0090.00622.96
8.2.160.0110.00620.35
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00421.23
8.2.120.0040.00426.35
8.2.110.0030.00721.16
8.2.100.0090.00317.97
8.2.90.0060.00318.15
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0080.00018.05
8.2.50.0060.00318.10
8.2.40.0040.00420.55
8.2.30.0040.00421.16
8.2.20.0000.00818.09
8.2.10.0000.00718.07
8.2.00.0050.00318.00
8.1.280.0040.01125.92
8.1.270.0060.00323.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.42
8.1.230.0080.00320.96
8.1.220.0030.00617.78
8.1.210.0040.00418.83
8.1.200.0030.00617.38
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0090.00318.60
8.1.160.0050.00218.95
8.1.150.0030.00618.92
8.1.140.0050.00219.46
8.1.130.0000.01118.84
8.1.120.0040.00417.55
8.1.110.0000.00817.57
8.1.100.0040.00417.61
8.1.90.0070.00317.61
8.1.80.0000.00717.62
8.1.70.0000.00717.48
8.1.60.0090.00017.81
8.1.50.0040.00417.58
8.1.40.0000.00817.66
8.1.30.0000.00817.81
8.1.20.0000.01117.70
8.1.10.0000.00817.77
8.1.00.0040.00417.66
8.0.300.0050.00220.08
8.0.290.0040.00416.88
8.0.280.0030.00318.52
8.0.270.0030.00617.39
8.0.260.0000.00917.04
8.0.250.0040.00417.16
8.0.240.0040.00417.09
8.0.230.0050.00217.06
8.0.220.0070.00016.98
8.0.210.0000.00717.05
8.0.200.0050.00317.15
8.0.190.0060.00617.04
8.0.180.0080.00017.11
8.0.170.0000.00717.11
8.0.160.0000.00717.23
8.0.150.0000.00717.10
8.0.140.0060.00317.07
8.0.130.0000.00513.57
8.0.120.0030.00517.05
8.0.110.0040.00417.16
8.0.100.0000.00717.14
8.0.90.0040.00417.14
8.0.80.0070.01117.08
8.0.70.0040.00416.94
8.0.60.0000.00716.91
8.0.50.0000.00817.17
8.0.30.0090.00817.25
8.0.20.0110.00917.47
8.0.10.0000.00717.21
8.0.00.0090.00917.02
7.4.330.0000.00615.55
7.4.320.0000.00616.81
7.4.300.0030.00316.82
7.4.290.0060.00316.81
7.4.280.0040.00416.82
7.4.270.0030.00316.81
7.4.260.0030.00316.80
7.4.250.0000.00816.79
7.4.240.0030.00516.82
7.4.230.0030.00316.63
7.4.220.0060.00916.77
7.4.210.0090.01016.78
7.4.200.0030.00516.92
7.4.160.0100.00716.72
7.4.150.0070.01017.40
7.4.140.0110.00717.86
7.4.130.0090.01216.71
7.4.120.0140.00916.65
7.4.110.0110.00616.48
7.4.100.0060.01216.73
7.4.90.0030.01316.60
7.4.80.0120.01219.39
7.4.70.0000.01616.60
7.4.60.0100.00916.59
7.4.50.0050.01216.68
7.4.40.0030.01316.76
7.4.30.0120.00616.70
7.4.00.0060.01315.03
7.3.330.0030.00613.54
7.3.320.0030.00313.33
7.3.310.0040.00416.51
7.3.300.0070.00016.53
7.3.290.0050.01016.55
7.3.280.0080.00816.51
7.3.270.0090.00917.40
7.3.260.0050.01116.65
7.3.250.0090.01016.59
7.3.240.0110.00716.66
7.3.230.0070.01716.52
7.3.210.0090.01016.93
7.3.200.0070.01016.37
7.3.190.0080.01216.52
7.3.180.0090.01016.49
7.3.170.0060.00916.71
7.3.160.0100.00716.54
7.3.120.0080.00614.92
7.3.110.0110.00414.77
7.3.100.0040.01114.78
7.3.90.0040.01015.16
7.3.80.0040.01114.94
7.3.70.0000.01215.11
7.3.60.0040.01114.77
7.3.50.0060.00615.04
7.3.40.0040.01114.78
7.3.30.0110.00314.78
7.3.20.0060.00916.94
7.3.10.0090.00816.88
7.3.00.0080.01016.80
7.2.330.0100.01016.73
7.2.320.0060.01016.64
7.2.310.0030.01316.84
7.2.300.0170.00716.70
7.2.290.0140.00316.71
7.2.240.0090.00615.13
7.2.230.0040.01115.11
7.2.220.0000.01315.29
7.2.210.0050.00415.16
7.2.200.0030.01215.25
7.2.190.0100.00715.27
7.2.180.0000.01715.07
7.2.170.0100.00315.31
7.2.160.0060.00815.31
7.2.150.0030.00616.95
7.2.140.0100.00317.14
7.2.130.0090.00716.92
7.2.120.0100.00716.90
7.2.110.0060.00916.92
7.2.100.0060.00616.92
7.2.90.0100.00516.97
7.2.80.0040.01617.09
7.2.70.0080.00817.02
7.2.60.0090.00517.18
7.2.50.0060.01316.95
7.2.40.0120.00817.00
7.2.30.0070.00916.86
7.2.20.0070.00916.95
7.2.10.0060.00916.88
7.2.00.0040.00917.91
7.1.330.0040.00816.23
7.1.320.0000.01016.07
7.1.310.0030.01016.00
7.1.300.0060.00315.88
7.1.290.0030.01015.67
7.1.280.0090.00616.06
7.1.270.0060.00616.09
7.1.260.0100.00016.00
7.1.250.0050.00816.09
7.1.200.0070.00715.99
7.1.100.0060.00617.93
7.1.70.0100.00317.48
7.1.60.0270.01335.41
7.1.50.0190.00934.96
7.1.40.0140.02034.90
7.1.30.0120.01634.86
7.1.20.0100.01734.89
7.1.10.0130.00616.74
7.1.00.0030.01016.88
7.0.200.0090.00317.02
7.0.190.0000.01316.81
7.0.180.0000.01316.21
7.0.170.0070.00716.21
7.0.160.0060.00616.29
7.0.150.0060.00916.48
7.0.140.0040.01216.35
7.0.130.0030.01016.79
7.0.120.0030.01016.74
7.0.110.0060.00616.43
7.0.100.0030.00916.51
7.0.90.0040.00816.38
7.0.80.0000.01216.23
7.0.70.0130.00316.54
7.0.60.0060.00616.26
7.0.50.0000.01116.39
7.0.40.0040.00816.50
7.0.30.0060.00616.57
7.0.20.0060.00616.60
7.0.10.0070.00716.69
7.0.00.0030.00916.60

preferences:
42.11 ms | 401 KiB | 5 Q