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()) { $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){ $str = str_replace($contextCondition[$key], $contextValues[$key], $str); } $message = $str; $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";

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.00318.66
8.3.50.0100.00922.14
8.3.40.0040.01119.04
8.3.30.0120.00319.21
8.3.20.0040.00420.24
8.3.10.0050.00323.66
8.3.00.0040.00422.34
8.2.180.0120.00918.54
8.2.170.0130.00722.96
8.2.160.0080.00822.18
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0060.00326.16
8.2.120.0000.00919.73
8.2.110.0160.00920.41
8.2.100.0040.01218.08
8.2.90.0080.00417.88
8.2.80.0080.00017.97
8.2.70.0090.00017.93
8.2.60.0050.00318.16
8.2.50.0000.00818.10
8.2.40.0020.00520.42
8.2.30.0030.00618.04
8.2.20.0040.00417.89
8.2.10.0080.00017.97
8.2.00.0040.00417.84
8.1.280.0110.00425.92
8.1.270.0090.00022.06
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0050.00522.10
8.1.230.0090.00319.10
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0040.00417.60
8.1.190.0080.00017.47
8.1.180.0040.00418.10
8.1.170.0060.00318.73
8.1.160.0040.00421.99
8.1.150.0080.00018.77
8.1.140.0050.00317.58
8.1.130.0030.00317.78
8.1.120.0030.00517.64
8.1.110.0000.00817.63
8.1.100.0040.00417.64
8.1.90.0000.00717.59
8.1.80.0070.00017.53
8.1.70.0000.00717.50
8.1.60.0030.00617.72
8.1.50.0090.00017.68
8.1.40.0040.00417.57
8.1.30.0030.00517.84
8.1.20.0040.00417.83
8.1.10.0090.00017.70
8.1.00.0070.00317.69
8.0.300.0060.00319.95
8.0.290.0000.00917.00
8.0.280.0000.00718.46
8.0.270.0040.00417.20
8.0.260.0000.00816.96
8.0.250.0050.00317.15
8.0.240.0000.00717.03
8.0.230.0000.00717.15
8.0.220.0000.00717.07
8.0.210.0070.00017.08
8.0.200.0000.00717.09
8.0.190.0070.00017.04
8.0.180.0040.00717.15
8.0.170.0040.00417.09
8.0.160.0060.00317.06
8.0.150.0040.00417.11
8.0.140.0040.00417.02
8.0.130.0030.00313.48
8.0.120.0000.00817.09
8.0.110.0060.00317.05
8.0.100.0040.00417.15
8.0.90.0050.00217.20
8.0.80.0090.00917.00
8.0.70.0000.00717.06
8.0.60.0040.00417.00
8.0.50.0040.00416.98
8.0.30.0130.01117.45
8.0.20.0080.01417.56
8.0.10.0070.00217.25
8.0.00.0150.00616.77
7.4.330.0000.00515.12
7.4.320.0030.00316.82
7.4.300.0000.00616.72
7.4.290.0050.00316.82
7.4.280.0000.00716.66
7.4.270.0030.00316.78
7.4.260.0000.00816.84
7.4.250.0040.00416.60
7.4.240.0020.00516.81
7.4.230.0000.00716.92
7.4.220.0060.01216.68
7.4.210.0090.00616.76
7.4.200.0040.00416.64
7.4.190.0000.00716.77
7.4.160.0130.00316.90
7.4.150.0090.00917.40
7.4.140.0150.00617.86
7.4.130.0150.00216.65
7.4.120.0120.00816.84
7.4.110.0120.00616.87
7.4.100.0110.01116.75
7.4.90.0140.00316.85
7.4.80.0090.00916.96
7.4.70.0040.00816.82
7.4.60.0030.01416.71
7.4.50.0030.00616.46
7.4.40.0060.00922.77
7.4.30.0090.01216.82
7.4.10.0080.00815.39
7.4.00.0050.01315.19
7.3.330.0050.00013.65
7.3.320.0030.00313.39
7.3.310.0050.00316.46
7.3.300.0030.00316.55
7.3.290.0060.00916.57
7.3.280.0110.00916.56
7.3.270.0120.00617.40
7.3.260.0150.01116.57
7.3.250.0060.01116.74
7.3.240.0060.01216.66
7.3.230.0120.00916.83
7.3.210.0130.00716.59
7.3.200.0090.01219.39
7.3.190.0090.00916.61
7.3.180.0060.01016.78
7.3.170.0130.00316.69
7.3.160.0150.00916.89
7.3.130.0100.00615.07
7.3.120.0060.01114.99
7.3.110.0100.00815.22
7.3.100.0090.00815.19
7.3.90.0020.01215.24
7.3.80.0080.00615.03
7.3.70.0050.01115.11
7.3.60.0060.00815.03
7.3.50.0070.00715.14
7.3.40.0130.00515.01
7.3.30.0050.00915.11
7.3.20.0070.01016.82
7.3.10.0090.00516.92
7.3.00.0050.01016.93
7.2.330.0150.00316.91
7.2.320.0030.01316.95
7.2.310.0140.00416.99
7.2.300.0090.00916.80
7.2.290.0070.01017.05
7.2.260.0060.01215.23
7.2.250.0130.00415.37
7.2.240.0060.00915.07
7.2.230.0030.01215.13
7.2.220.0120.00315.38
7.2.210.0020.01415.34
7.2.200.0050.00915.18
7.2.190.0070.01115.16
7.2.180.0070.00415.16
7.2.170.0070.00715.15
7.2.160.0050.00515.36
7.2.150.0010.01116.99
7.2.140.0110.00517.27
7.2.130.0050.00917.13
7.2.120.0080.00517.21
7.2.110.0060.00817.06
7.2.100.0070.00517.27
7.2.90.0070.00817.13
7.2.80.0100.00517.10
7.2.70.0020.01417.07
7.2.60.0080.00616.95
7.2.50.0110.00516.96
7.2.40.0090.00517.28
7.2.30.0050.01017.13
7.2.20.0040.00817.01
7.2.10.0060.01017.18
7.2.00.0080.00517.22
7.1.330.0030.01216.09
7.1.320.0060.00916.11
7.1.310.0040.01315.96
7.1.300.0040.00916.07
7.1.290.0060.00615.76
7.1.280.0090.00315.89
7.1.270.0070.00715.98
7.1.260.0060.00615.95
7.1.250.0060.00715.75
7.1.240.0030.00816.10
7.1.230.0060.01015.92
7.1.220.0060.00615.88
7.1.210.0020.01015.94
7.1.200.0080.00516.08
7.1.190.0070.00715.96
7.1.180.0130.00316.10
7.1.170.0060.00615.82
7.1.160.0050.00816.03
7.1.150.0050.00815.91
7.1.140.0070.00515.88
7.1.130.0070.00715.93
7.1.120.0070.00816.05
7.1.110.0090.00416.11
7.1.100.0030.01115.91
7.1.90.0030.01216.03
7.1.80.0070.00915.94
7.1.70.0060.00616.55
7.1.60.0050.01316.99
7.1.50.0100.01122.41
7.1.40.0090.00515.97
7.1.30.0050.00915.99
7.1.20.0070.00616.10
7.1.10.0080.00515.86
7.1.00.0040.03218.13
7.0.330.0050.00515.61
7.0.320.0040.00715.61
7.0.310.0070.00515.35
7.0.300.0040.00715.61
7.0.290.0060.00415.57
7.0.280.0080.00515.67
7.0.270.0050.00715.65
7.0.260.0050.00515.53
7.0.250.0050.00715.54
7.0.240.0050.01015.56
7.0.230.0040.01215.47
7.0.220.0090.00315.64
7.0.210.0040.00815.63
7.0.200.0040.00715.93
7.0.190.0050.00715.55
7.0.180.0080.00615.63
7.0.170.0020.01315.60
7.0.160.0030.00615.66
7.0.150.0030.01215.61
7.0.140.0080.02717.70
7.0.130.0030.01015.76
7.0.120.0080.00515.37
7.0.110.0090.00315.70
7.0.100.0050.01917.08
7.0.90.0130.03117.02
7.0.80.0120.03017.08
7.0.70.0110.02717.03
7.0.60.0090.03417.00
7.0.50.0040.03417.24
7.0.40.0070.01915.87
7.0.30.0070.03415.76
7.0.20.0040.03415.84
7.0.10.0060.03315.81
7.0.00.0070.02815.72
5.6.400.0100.00214.50
5.6.390.0040.00814.57
5.6.380.0080.00514.43
5.6.370.0040.01114.52
5.6.360.0050.00514.47
5.6.350.0070.00714.66
5.6.340.0070.00514.47
5.6.330.0050.01114.61
5.6.320.0080.00514.66
5.6.310.0050.01114.54
5.6.300.0060.00814.42
5.6.290.0050.00514.39
5.6.280.0080.02616.66
5.6.270.0060.00914.61
5.6.260.0030.00614.67
5.6.250.0100.02016.65
5.6.240.0060.02416.54
5.6.230.0070.02916.52
5.6.220.0070.03016.50
5.6.210.0060.03116.39
5.6.200.0050.03116.60
5.6.190.0080.03016.72
5.6.180.0080.03316.76
5.6.170.0070.03316.64
5.6.160.0080.03016.84
5.6.150.0060.03316.58
5.6.140.0030.03816.77
5.6.130.0080.03016.74
5.6.120.0060.03416.71
5.6.110.0070.03116.63
5.6.100.0080.03316.61
5.6.90.0050.03316.71
5.6.80.0040.03616.58
5.6.70.0060.02316.45
5.6.60.0070.03216.42
5.6.50.0090.03016.46
5.6.40.0060.02916.43
5.6.30.0060.03016.37
5.6.20.0060.03016.40
5.6.10.0130.02616.40
5.6.00.0010.03716.51
5.5.380.0070.03116.43
5.5.370.0070.02316.58
5.5.360.0030.03016.29
5.5.350.0020.03716.50
5.5.340.0060.02016.64
5.5.330.0050.02316.59
5.5.320.0080.02916.63
5.5.310.0040.02116.57
5.5.300.0090.03016.62
5.5.290.0040.03516.58
5.5.280.0050.03316.56
5.5.270.0090.02716.67
5.5.260.0090.03216.65
5.5.250.0030.02816.27
5.5.240.0080.03016.30
5.5.230.0080.02716.37
5.5.220.0060.03416.26
5.5.210.0050.02416.44
5.5.200.0060.03116.27
5.5.190.0060.03216.34
5.5.180.0060.02216.27
5.5.170.0060.00914.36
5.5.160.0080.02016.35
5.5.150.0050.02916.23
5.5.140.0080.02916.38
5.5.130.0080.03116.45
5.5.120.0060.02616.44
5.5.110.0100.02716.15
5.5.100.0060.03316.28
5.5.90.0060.03016.25
5.5.80.0070.03016.30
5.5.70.0040.03516.14
5.5.60.0030.03616.19
5.5.50.0080.02716.37
5.5.40.0090.02716.28
5.5.30.0030.03416.32
5.5.20.0100.02716.31
5.5.10.0050.03216.22
5.5.00.0060.01616.28
5.4.450.0050.03214.01
5.4.440.0050.02613.86
5.4.430.0060.03113.91
5.4.420.0020.03413.97
5.4.410.0060.03013.90
5.4.400.0030.02013.68
5.4.390.0060.03313.73
5.4.380.0050.03113.94
5.4.370.0070.02613.83
5.4.360.0010.03313.76
5.4.350.0040.03313.85
5.4.340.0030.02213.73
5.4.330.0070.00111.30
5.4.320.0030.02813.94
5.4.310.0040.02713.88
5.4.300.0060.02713.75
5.4.290.0060.02813.89
5.4.280.0060.02113.89
5.4.270.0050.02813.84
5.4.260.0090.02313.65
5.4.250.0040.02713.76
5.4.240.0020.02513.83
5.4.230.0070.02413.86
5.4.220.0020.03413.77
5.4.210.0080.02513.81
5.4.200.0100.02513.92
5.4.190.0040.03013.86
5.4.180.0070.01813.87
5.4.170.0060.02413.92
5.4.160.0060.02813.76
5.4.150.0070.02813.82
5.4.140.0070.02913.06
5.4.130.0050.02612.82
5.4.120.0040.02513.07
5.4.110.0070.02812.96
5.4.100.0020.03013.00
5.4.90.0050.02712.84
5.4.80.0070.01812.97
5.4.70.0050.03013.02
5.4.60.0050.02712.86
5.4.50.0060.01612.87
5.4.40.0090.02413.07
5.4.30.0040.02112.92
5.4.20.0030.02512.81
5.4.10.0050.02412.97
5.4.00.0070.02712.62
5.3.290.0040.01812.46
5.3.280.0050.02812.36
5.3.270.0070.02812.46
5.3.260.0020.02112.45
5.3.250.0070.02812.30
5.3.240.0060.01612.31
5.3.230.0030.02912.33
5.3.220.0060.02812.36
5.3.210.0090.02612.27
5.3.200.0040.02412.31
5.3.190.0050.02912.44
5.3.180.0020.02712.53
5.3.170.0010.02012.51
5.3.160.0060.02812.56
5.3.150.0040.03112.45
5.3.140.0070.02912.47
5.3.130.0050.02912.44
5.3.120.0040.02812.43
5.3.110.0020.03212.49
5.3.100.0020.02212.42
5.3.90.0070.03012.38
5.3.80.0010.02012.24
5.3.70.0030.03012.32
5.3.60.0060.02812.31
5.3.50.0040.02912.39
5.3.40.0040.03112.36
5.3.30.0040.03012.33
5.3.20.0070.02312.34
5.3.10.0060.01912.26
5.3.00.0040.01912.24
5.2.170.0100.05715.78
5.2.160.0130.05715.78
5.2.150.0130.05715.78
5.2.140.0100.05715.78
5.2.130.0070.05015.78
5.2.120.0000.04015.78
5.2.110.0070.05715.78
5.2.100.0070.06015.78
5.2.90.0070.06015.78
5.2.80.0130.02715.78
5.2.70.0070.06015.78
5.2.60.0070.06015.78
5.2.50.0100.05015.78
5.2.40.0030.06315.78
5.2.30.0070.05315.78
5.2.20.0030.06315.78
5.2.10.0030.05315.78
5.2.00.0070.06715.78
5.1.60.0000.03315.78
5.1.50.0070.04715.78
5.1.40.0070.05015.78
5.1.30.0030.05715.78
5.1.20.0070.05015.78
5.1.10.0100.04015.78
5.1.00.0030.05015.78
5.0.50.0000.05015.78
5.0.40.0100.04015.78
5.0.30.0070.06015.78
5.0.20.0100.03315.78
5.0.10.0000.04715.78
5.0.00.0000.06715.78
4.4.90.0030.01315.78
4.4.80.0000.03315.78
4.4.70.0000.03715.78
4.4.60.0000.03015.78
4.4.50.0030.03315.78
4.4.40.0030.04715.78
4.4.30.0070.03015.78
4.4.20.0030.03315.78
4.4.10.0030.03715.78
4.4.00.0000.05315.78
4.3.110.0100.02715.78
4.3.100.0000.01715.78
4.3.90.0000.03315.78
4.3.80.0030.05015.78
4.3.70.0070.01315.78
4.3.60.0030.03315.78
4.3.50.0030.03315.78
4.3.40.0000.05015.78
4.3.30.0000.03715.78
4.3.20.0000.03015.78
4.3.10.0070.03015.78
4.3.00.0000.03715.78

preferences:
51.7 ms | 401 KiB | 5 Q