3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'Showing results [program=for {program} programs|No pogram at all] [province=in {province}] [degree=with degree of {degree}]'; function interpolateString($message, array $context = array()) { $replace = array(); foreach ($context as $key => $val) { $replace['{' . $key . '}'] = $val; } return strtr($message, $replace); } $arrContext = array( 'program' => 'Nursing', 'province' => 'Ontario', 'degree' => false ); //echo interpolateString($str, $arrContext); echo "\n"; $arrMatches = array(); preg_match_all("/\[(\w+)\=([^\[\]\|.*]*)?\|*([^\[\].*]*)\]/", $str, $arrMatches); $contextKeys = $arrMatches[1]; $contextCondition = array(); $contextValues = array(); $i = 0; foreach ($contextKeys as $key){ $contextCondition += array($key => $arrMatches[0][$i]); $i++;} $i = 0; foreach ($contextKeys as $key){ $value = $arrContext[$key] != false ? 2 : 3; $contextValues += array($key => $arrMatches[$value][$i]); $i++;} foreach ($contextKeys as $key){ echo "{$key} -> {$contextCondition[$key]} -> {$contextValues[$key]}\n"; }

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.0150.00617.00
8.3.60.0100.00716.50
8.3.50.0140.01022.10
8.3.40.0080.00818.91
8.3.30.0070.00719.16
8.3.20.0040.00420.20
8.3.10.0080.00023.56
8.3.00.0100.00019.63
8.2.180.0130.01018.41
8.2.170.0140.00722.96
8.2.160.0070.01020.38
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0070.00726.16
8.2.120.0030.00522.37
8.2.110.0030.00622.22
8.2.100.0060.00617.91
8.2.90.0000.00819.18
8.2.80.0000.00817.97
8.2.70.0080.00017.75
8.2.60.0120.00018.03
8.2.50.0050.00318.07
8.2.40.0040.00418.34
8.2.30.0040.00418.22
8.2.20.0000.00717.97
8.2.10.0030.00517.86
8.2.00.0000.00817.94
8.1.280.0100.00725.92
8.1.270.0060.00322.05
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0040.00823.68
8.1.230.0000.01119.02
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0090.00017.50
8.1.190.0000.00817.40
8.1.180.0000.00818.10
8.1.170.0040.00818.83
8.1.160.0000.00722.05
8.1.150.0000.00818.80
8.1.140.0000.00817.50
8.1.130.0030.00317.87
8.1.120.0040.00317.59
8.1.110.0030.00517.48
8.1.100.0000.00717.69
8.1.90.0050.00217.63
8.1.80.0030.00317.52
8.1.70.0000.00717.53
8.1.60.0080.00017.75
8.1.50.0060.00317.67
8.1.40.0040.00417.59
8.1.30.0000.00817.86
8.1.20.0060.00317.70
8.1.10.0000.00817.68
8.1.00.0050.00317.59
8.0.300.0040.00418.77
8.0.290.0020.00517.16
8.0.280.0030.00318.45
8.0.270.0040.00417.32
8.0.260.0000.00717.04
8.0.250.0040.00417.25
8.0.240.0000.00717.08
8.0.230.0060.00317.22
8.0.220.0000.00817.08
8.0.210.0070.00017.14
8.0.200.0060.00017.17
8.0.190.0050.00317.21
8.0.180.0050.00517.13
8.0.170.0000.00717.20
8.0.160.0030.00517.17
8.0.150.0050.00217.05
8.0.140.0000.00817.08
8.0.130.0040.00413.54
8.0.120.0000.00717.11
8.0.110.0040.00417.03
8.0.100.0000.00717.07
8.0.90.0030.00517.05
8.0.80.0060.01017.11
8.0.70.0040.00417.07
8.0.60.0040.00416.97
8.0.50.0050.00216.99
8.0.30.0090.01017.20
8.0.20.0120.00817.40
8.0.10.0040.00417.36
8.0.00.0110.00717.00
7.4.330.0000.00515.00
7.4.320.0060.00016.82
7.4.300.0030.00316.59
7.4.290.0030.00316.70
7.4.280.0030.00316.81
7.4.270.0000.00816.78
7.4.260.0030.00316.84
7.4.250.0050.00316.80
7.4.240.0030.00416.75
7.4.230.0070.00016.77
7.4.220.0120.01616.77
7.4.210.0090.00416.85
7.4.200.0000.00816.53
7.4.190.0000.00716.78
7.4.160.0040.01216.77
7.4.150.0170.00317.40
7.4.140.0100.00717.86
7.4.130.0020.01516.83
7.4.120.0120.00916.74
7.4.110.0140.00616.78
7.4.100.0140.01116.72
7.4.90.0070.01016.65
7.4.80.0030.01519.39
7.4.70.0140.00316.67
7.4.60.0110.00716.72
7.4.50.0000.00516.37
7.4.40.0030.01322.77
7.4.30.0080.00816.86
7.4.00.0020.01415.31
7.3.330.0000.00513.53
7.3.320.0000.00613.51
7.3.310.0030.00316.43
7.3.300.0030.00316.50
7.3.290.0030.01716.54
7.3.280.0030.01416.48
7.3.270.0100.00717.40
7.3.260.0050.01116.76
7.3.250.0070.01216.62
7.3.240.0140.00316.55
7.3.230.0140.00816.67
7.3.210.0150.00416.55
7.3.200.0110.01119.39
7.3.190.0070.01416.48
7.3.180.0090.01216.71
7.3.170.0060.01016.88
7.3.160.0120.00616.57
7.3.120.0070.01114.99
7.3.110.0070.01015.34
7.3.100.0000.01815.28
7.3.90.0070.00715.05
7.3.80.0070.01115.02
7.3.70.0000.01614.86
7.3.60.0030.00915.15
7.3.50.0030.01215.19
7.3.40.0030.01514.75
7.3.30.0110.00414.76
7.3.20.0100.00717.08
7.3.10.0070.00717.06
7.3.00.0070.00717.05
7.2.330.0150.00316.81
7.2.320.0060.00916.96
7.2.310.0160.00616.81
7.2.300.0030.01316.81
7.2.290.0070.01116.87
7.2.250.0070.01015.03
7.2.240.0030.01315.38
7.2.230.0070.01315.26
7.2.220.0100.01015.43
7.2.210.0030.01615.08
7.2.200.0090.00615.35
7.2.190.0090.00615.36
7.2.180.0070.00715.33
7.2.170.0110.00315.37
7.1.330.0040.01115.68
7.1.320.0100.00616.04
7.1.310.0000.01316.13
7.1.300.0110.00315.70
7.1.290.0040.01116.18
7.1.280.0040.00815.67
7.1.270.0030.01016.15
7.1.260.0030.00916.11
7.1.70.0030.00317.55
7.1.60.0150.00919.31
7.1.50.0250.01335.03
7.1.00.0000.08022.54
7.0.200.0100.00717.06
7.0.140.0070.07022.21
7.0.100.0100.04320.04
7.0.90.0030.04319.86
7.0.80.0000.05019.91
7.0.70.0070.03719.94
7.0.60.0070.04319.89
7.0.50.0100.03720.26
7.0.40.0000.04320.17
7.0.30.0100.03320.05
7.0.20.0070.04320.08
7.0.10.0070.03720.12
7.0.00.0030.04320.17
5.6.280.0000.07721.05
5.6.250.0000.05320.54
5.6.240.0000.05020.73
5.6.230.0100.03320.76
5.6.220.0070.03320.66
5.6.210.0030.03720.69
5.6.200.0130.05021.12
5.6.190.0170.03021.05
5.6.180.0070.03721.18
5.6.170.0030.04320.96
5.6.160.0030.04721.05
5.6.150.0070.04021.18
5.6.140.0030.04320.96
5.6.130.0130.02721.09
5.6.120.0030.04321.11
5.6.110.0030.04321.05
5.6.100.0070.04020.93
5.6.90.0070.03321.13
5.6.80.0070.03720.50
5.6.70.0030.03720.48
5.6.60.0000.04020.48
5.6.50.0030.03720.51
5.6.40.0000.08720.41
5.6.30.0200.07020.47
5.6.20.0170.03320.42
5.6.10.0030.07320.32
5.6.00.0030.05020.48
5.5.380.0130.03320.43
5.5.370.0030.04320.40
5.5.360.0100.02720.35
5.5.350.0030.04320.38
5.5.340.0100.03020.93
5.5.330.0030.04020.85
5.5.320.0000.03720.95
5.5.310.0070.04020.79
5.5.300.0030.03720.77
5.5.290.0030.04320.93
5.5.280.0070.04020.87
5.5.270.0030.04320.69
5.5.260.0070.04020.89
5.5.250.0070.03720.62
5.5.240.0000.04020.32
5.5.230.0070.04320.07
5.5.220.0070.03720.21
5.5.210.0100.04020.27
5.5.200.0170.02720.24
5.5.190.0030.08720.26
5.5.180.0030.06020.14
5.5.160.0030.08320.24
5.5.150.0130.06320.23
5.5.140.0070.07720.18
5.5.130.0100.07720.26
5.5.120.0170.07020.27
5.5.110.0030.08320.16
5.5.100.0070.08020.03
5.5.90.0200.07020.18
5.5.80.0170.06720.09
5.5.70.0100.07720.02
5.5.60.0070.07020.06
5.5.50.0070.08319.95
5.5.40.0100.07319.95
5.5.30.0070.08020.16
5.5.20.0130.07020.09
5.5.10.0100.08020.05
5.5.00.0100.07319.99
5.4.450.0000.04019.56
5.4.440.0030.04019.45
5.4.430.0030.04019.41
5.4.420.0100.03319.35
5.4.410.0000.04019.37
5.4.400.0030.03019.04
5.4.390.0030.03719.05
5.4.380.0030.07318.91
5.4.370.0100.03019.13
5.4.360.0030.04019.05
5.4.350.0070.04319.03
5.4.340.0100.07319.09
5.4.320.0030.07319.03
5.4.310.0170.05718.95
5.4.300.0200.06319.03
5.4.290.0130.07319.13
5.4.280.0100.06719.13
5.4.270.0030.07719.17
5.4.260.0070.04318.84
5.4.250.0100.06719.09
5.4.240.0100.04019.13
5.4.230.0100.07318.84
5.4.220.0070.07318.87
5.4.210.0070.07018.95
5.4.200.0070.06719.04
5.4.190.0070.07718.89
5.4.180.0000.08319.08
5.4.170.0070.07719.17
5.4.160.0030.07319.11
5.4.150.0170.07318.82
5.4.140.0000.07016.45
5.4.130.0070.07016.51
5.4.120.0030.03716.33
5.4.110.0030.08316.47
5.4.100.0130.07016.32
5.4.90.0070.07316.45
5.4.80.0130.07016.42
5.4.70.0100.07016.43
5.4.60.0070.06716.43
5.4.50.0030.04316.38
5.4.40.0070.06716.35
5.4.30.0030.05016.25
5.4.20.0130.03316.29
5.4.10.0070.04016.30
5.4.00.0000.06315.86
5.3.290.0100.06714.77
5.3.280.0030.07014.55
5.3.270.0130.06314.57
5.3.260.0030.08014.55
5.3.250.0070.08014.59
5.3.240.0000.07314.67
5.3.230.0030.07714.68
5.3.220.0070.07014.54
5.3.210.0070.07714.58
5.3.200.0000.08314.72
5.3.190.0030.07714.56
5.3.180.0070.06314.64
5.3.170.0070.07314.54
5.3.160.0030.04314.64
5.3.150.0030.07714.53
5.3.140.0070.07314.63
5.3.130.0030.08014.70
5.3.120.0100.07714.70
5.3.110.0170.05714.59
5.3.100.0130.07014.02
5.3.90.0000.07014.02
5.3.80.0100.05014.03
5.3.70.0070.05314.09
5.3.60.0070.07313.99
5.3.50.0000.04314.05
5.3.40.0070.07314.02
5.3.30.0100.06313.99
5.3.20.0100.06313.77
5.3.10.0100.06313.60
5.3.00.0130.06013.79
5.2.170.0100.04311.16
5.2.160.0030.05711.16
5.2.150.0070.06311.18
5.2.140.0030.05311.29
5.2.130.0070.06010.99
5.2.120.0070.06311.13
5.2.110.0100.04011.25
5.2.100.0070.06011.16
5.2.90.0030.04311.22
5.2.80.0070.06311.16
5.2.70.0070.05311.17
5.2.60.0000.03310.98
5.2.50.0030.03311.05
5.2.40.0000.04311.04
5.2.30.0170.05311.10
5.2.20.0100.05310.84
5.2.10.0070.06011.00
5.2.00.0070.05710.79
5.1.60.0170.03710.09
5.1.50.0030.04710.10
5.1.40.0030.0539.82
5.1.30.0100.05010.46
5.1.20.0030.03010.51
5.1.10.0000.04310.12
5.1.00.0070.04710.18
5.0.50.0070.0379.07
5.0.40.0070.0309.07
5.0.30.0070.0409.07
5.0.20.0030.0439.07
5.0.10.0100.0339.07
5.0.00.0030.0609.07
4.4.90.0000.0209.07
4.4.80.0000.0409.07
4.4.70.0070.0279.07
4.4.60.0000.0379.07
4.4.50.0030.0309.07
4.4.40.0030.0539.07
4.4.30.0030.0339.07
4.4.20.0000.0339.07
4.4.10.0030.0309.07
4.4.00.0030.0539.07
4.3.110.0000.0279.07
4.3.100.0000.0309.07
4.3.90.0030.0409.07
4.3.80.0030.0479.07
4.3.70.0000.0379.07
4.3.60.0000.0379.07
4.3.50.0030.0339.07
4.3.40.0030.0439.07
4.3.30.0000.0339.07
4.3.20.0000.0379.07
4.3.10.0000.0339.07
4.3.00.0000.0409.07

preferences:
43.54 ms | 401 KiB | 5 Q