3v4l.org

run code in 300+ PHP versions simultaneously
<?php function template($template, $vals) { $matches = array(); $regex = "/\{\{(\S+)\}\}/e"; $rendered = $template; // in case no matches are found preg_match_all($regex, $template, $matches, PREG_OFFSET_CAPTURE, 3); foreach ($matches[0] as $found) { $block = $found[0]; $offset = $found[0]; $k = str_replace('{{', '', $block); $k = str_replace('}-}', '', $k); $rendered = preg_replace($regex, '$vals[\\1]', $template); } return $rendered; } $template = "test {{ME}}."; $vals = array('ME' => 'beep'); echo template($template, $vals);

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.40.0120.00318.84
8.3.30.0070.00718.84
8.3.20.0040.00420.27
8.3.10.0000.00723.53
8.3.00.0050.00223.67
8.2.170.0150.00018.79
8.2.160.0030.01022.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0000.00819.76
8.2.120.0000.00826.35
8.2.110.0040.00422.31
8.2.100.0000.01118.05
8.2.90.0050.00319.30
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0000.00817.80
8.2.50.0050.00318.07
8.2.40.0000.00922.15
8.2.30.0000.00720.66
8.2.20.0000.00717.91
8.2.10.0040.00418.16
8.2.00.0000.00718.15
8.1.270.0040.00423.68
8.1.260.0000.00828.09
8.1.250.0040.00428.09
8.1.240.0030.00623.92
8.1.230.0040.00719.09
8.1.220.0060.00317.79
8.1.210.0050.00318.77
8.1.200.0030.00617.22
8.1.190.0000.00817.25
8.1.180.0030.00518.10
8.1.170.0000.00918.59
8.1.160.0000.00720.68
8.1.150.0050.00318.92
8.1.140.0050.00319.52
8.1.130.0030.00317.79
8.1.120.0070.00017.59
8.1.110.0100.00017.39
8.1.100.0050.00217.55
8.1.90.0040.00417.53
8.1.80.0000.00817.47
8.1.70.0040.00417.44
8.1.60.0040.00417.60
8.1.50.0040.00417.46
8.1.40.0070.00317.55
8.1.30.0040.00417.52
8.1.20.0060.00317.59
8.1.10.0050.00317.63
8.1.00.0040.00417.43
8.0.300.0000.00718.77
8.0.290.0080.00016.75
8.0.280.0030.00318.39
8.0.270.0000.00717.29
8.0.260.0000.00817.34
8.0.250.0000.00717.02
8.0.240.0080.00016.90
8.0.230.0030.00317.07
8.0.220.0040.00416.89
8.0.210.0000.00716.88
8.0.200.0030.00317.04
8.0.190.0000.00816.98
8.0.180.0060.00317.05
8.0.170.0000.00817.00
8.0.160.0040.00416.96
8.0.150.0070.00016.93
8.0.140.0030.00316.94
8.0.130.0050.00013.50
8.0.120.0030.00516.96
8.0.110.0070.00016.82
8.0.100.0070.00017.02
8.0.90.0070.00016.84
8.0.80.0100.00616.97
8.0.70.0000.00716.79
8.0.60.0070.00017.02
8.0.50.0040.00416.77
8.0.30.0120.00717.17
8.0.20.0120.00717.40
8.0.10.0030.00517.11
8.0.00.0120.00816.80
7.4.330.0000.00516.63
7.4.320.0030.00316.68
7.4.300.0060.00016.53
7.4.290.0070.00016.54
7.4.280.0040.00716.54
7.4.270.0000.00716.46
7.4.260.0070.00016.49
7.4.250.0050.00216.49
7.4.240.0020.00716.54
7.4.230.0040.00416.61
7.4.220.0120.00616.63
7.4.210.0090.00616.64
7.4.200.0030.00316.70
7.4.160.0090.00916.45
7.4.150.0130.00317.40
7.4.140.0150.00917.86
7.4.130.0150.00416.66
7.4.120.0060.01416.60
7.4.110.0110.00916.63
7.4.100.0160.00616.57
7.4.90.0030.01316.43
7.4.80.0140.00319.39
7.4.70.0110.00516.60
7.4.60.0140.00316.57
7.4.50.0070.00716.34
7.4.40.0050.01116.52
7.4.30.0090.00616.51
7.4.00.0100.00614.77
7.3.330.0030.00313.40
7.3.320.0080.00013.23
7.3.310.0050.00216.50
7.3.300.0000.00716.40
7.3.290.0030.00316.29
7.3.280.0130.00416.36
7.3.270.0140.00317.40
7.3.260.0060.01016.23
7.3.250.0110.00716.57
7.3.240.0080.01016.51
7.3.230.0080.00916.58
7.3.210.0110.00516.50
7.3.200.0150.00319.39
7.3.190.0090.00916.46
7.3.180.0070.01016.67
7.3.170.0040.01116.55
7.3.160.0060.01216.39
7.2.330.0120.00616.77
7.2.320.0110.01116.96
7.2.310.0070.01016.79
7.2.300.0100.01316.84
7.2.290.0060.01016.88
7.2.60.0110.00816.96
7.2.00.0070.00419.63
7.1.200.0120.00015.96
7.1.100.0040.00418.61
7.1.70.0070.00017.29
7.1.60.0160.00919.20
7.1.50.0070.01417.16
7.1.00.0130.06722.30
7.0.200.0000.00816.71
7.0.60.0030.08021.71
7.0.50.0000.04717.90
7.0.40.0070.04320.07
7.0.30.0300.04320.28
7.0.20.0300.04720.25
7.0.10.0130.04020.22
7.0.00.0100.07320.27
5.6.280.0070.03021.10
5.6.210.0030.04320.60
5.6.200.0070.07018.28
5.6.190.0030.04320.56
5.6.180.0530.06720.41
5.6.170.0330.07020.44
5.6.160.0070.04020.46
5.6.150.0070.03718.27
5.6.140.0030.05718.18
5.6.130.0070.05318.20
5.6.120.0100.08020.98
5.6.110.0070.08320.99
5.6.100.0100.05020.98
5.6.90.0100.05721.13
5.6.80.0200.06720.54
5.5.350.0330.03320.34
5.5.340.0070.05318.09
5.5.330.0070.05020.37
5.5.320.0300.05020.31
5.5.310.0300.05720.24
5.5.300.0170.06717.98
5.5.290.0030.09017.99
5.5.280.0030.07020.88
5.5.270.0070.08020.96
5.5.260.0130.06020.87
5.5.250.0200.07320.70
5.5.240.0200.07720.29

preferences:
54.96 ms | 400 KiB | 5 Q