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.60.0110.00817.00
8.3.50.0140.00016.52
8.3.40.0060.01519.10
8.3.30.0090.00618.95
8.3.20.0050.00321.95
8.3.10.0050.00323.66
8.3.00.0040.00419.63
8.2.180.0170.00318.66
8.2.170.0090.00622.96
8.2.160.0120.00320.50
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0050.00321.04
8.2.120.0040.00426.35
8.2.110.0030.00621.11
8.2.100.0080.00417.87
8.2.90.0060.00318.28
8.2.80.0040.00417.97
8.2.70.0030.00617.50
8.2.60.0030.00517.93
8.2.50.0040.00418.10
8.2.40.0040.00420.46
8.2.30.0040.00421.06
8.2.20.0070.00018.08
8.2.10.0050.00218.03
8.2.00.0040.00418.21
8.1.280.0070.00725.92
8.1.270.0040.00423.96
8.1.260.0090.00026.35
8.1.250.0000.00828.09
8.1.240.0030.00920.83
8.1.230.0070.00421.03
8.1.220.0030.00517.78
8.1.210.0000.00818.93
8.1.200.0040.00417.60
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0070.00318.75
8.1.160.0030.00519.05
8.1.150.0000.01118.93
8.1.140.0020.00519.53
8.1.130.0050.00318.91
8.1.120.0040.00417.65
8.1.110.0070.00017.63
8.1.100.0060.00317.59
8.1.90.0100.00017.61
8.1.80.0000.00717.68
8.1.70.0050.00317.48
8.1.60.0000.00817.66
8.1.50.0000.00817.59
8.1.40.0000.00817.59
8.1.30.0000.00917.85
8.1.20.0140.00017.79
8.1.10.0080.00017.76
8.1.00.0030.00517.67
8.0.300.0000.00720.21
8.0.290.0040.00416.88
8.0.280.0000.00718.40
8.0.270.0000.00717.23
8.0.260.0080.00316.96
8.0.250.0000.00717.05
8.0.240.0040.00417.14
8.0.230.0070.00017.17
8.0.220.0000.00817.12
8.0.210.0030.00317.02
8.0.200.0030.00317.09
8.0.190.0030.00617.18
8.0.180.0000.00717.02
8.0.170.0000.00817.18
8.0.160.0050.00217.09
8.0.150.0000.00817.12
8.0.140.0090.00317.08
8.0.130.0000.00613.47
8.0.120.0080.00017.06
8.0.110.0040.00417.18
8.0.100.0040.00417.07
8.0.90.0040.00417.18
8.0.80.0140.00617.16
8.0.70.0040.00417.07
8.0.60.0040.00416.97
8.0.50.0000.00716.98
8.0.30.0130.00517.25
8.0.20.0100.01017.40
8.0.10.0040.00417.04
8.0.00.0090.00917.11
7.4.330.0000.00515.55
7.4.320.0060.00016.87
7.4.300.0000.00716.80
7.4.290.0030.00716.62
7.4.280.0040.00416.86
7.4.270.0050.00216.80
7.4.260.0040.00413.50
7.4.250.0060.00316.70
7.4.240.0080.00016.82
7.4.230.0070.00016.55
7.4.220.0090.00716.74
7.4.210.0130.00316.74
7.4.200.0040.00416.87
7.4.160.0070.01316.62
7.4.150.0120.00617.40
7.4.140.0100.00917.86
7.4.130.0060.01916.80
7.4.120.0090.01216.78
7.4.110.0190.00016.73
7.4.100.0030.01316.89
7.4.90.0100.00716.68
7.4.80.0120.00919.39
7.4.70.0100.00716.73
7.4.60.0090.00916.77
7.4.50.0090.00516.47
7.4.40.0160.00016.75
7.4.30.0120.00416.79
7.4.00.0040.01415.32
7.3.330.0050.00313.38
7.3.320.0000.00513.54
7.3.310.0070.00316.42
7.3.300.0000.00716.48
7.3.290.0050.00916.54
7.3.280.0080.00916.50
7.3.270.0090.00917.40
7.3.260.0140.00416.78
7.3.250.0100.00816.74
7.3.240.0120.00716.71
7.3.230.0060.01216.77
7.3.210.0130.01016.42
7.3.200.0080.00916.66
7.3.190.0030.01316.55
7.3.180.0070.01016.34
7.3.170.0130.00316.85
7.3.160.0060.01016.47
7.2.330.0070.01316.87
7.2.320.0090.00916.89
7.2.310.0100.00616.88
7.2.300.0100.00716.94
7.2.290.0110.00716.98
7.2.60.0060.00317.14
7.2.00.0260.00319.72
7.1.200.0080.00815.67
7.1.100.0060.00618.61
7.1.70.0000.01117.06
7.1.60.0100.01635.45
7.1.50.0190.00735.01
7.1.40.0160.01034.78
7.1.30.0190.00634.76
7.1.20.0200.00734.74
7.1.10.0050.00816.98
7.1.00.0030.00916.99
7.0.200.0060.00616.61
7.0.190.0070.00416.82
7.0.180.0000.01216.29
7.0.170.0060.00616.34
7.0.160.0100.00516.23
7.0.150.0030.01016.38
7.0.140.0000.01216.39
7.0.130.0030.01016.65
7.0.120.0060.00616.61
7.0.110.0000.01216.40
7.0.100.0000.01116.61
7.0.90.0060.00616.65
7.0.80.0000.01216.53
7.0.70.0060.00616.35
7.0.60.0090.00316.41
7.0.50.0030.00916.41
7.0.40.0050.00816.51
7.0.30.0060.00616.71
7.0.20.0060.00616.50
7.0.10.0000.01316.78
7.0.00.0040.00816.55

preferences:
51.44 ms | 400 KiB | 5 Q