3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Hello {{ name }}, nice to meet you.'; define('TAG_OPEN', '{{'); define('TAG_CLOSE', '}}'); define('STATE_TEXT', 'STATE_TEXT'); define('STATE_IN_TAG', 'STATE_IN_TAG'); function isOpenTag($string, $index) { return TAG_OPEN === substr($string, $index, strlen(TAG_OPEN)); } function isCloseTag($string, $index) { return TAG_CLOSE === substr($string, $index, strlen(TAG_CLOSE)); } function isText($string, $index) { return ! (isOpenTag($string, $index) || isCloseTag($string, $index)); } $state = STATE_TEXT; for($index = 0; $index < strlen($string); $index++) { if (isText($string, $index) && $state != STATE_IN_TAG) { continue; } if (isOpenTag($string, $index)) { $state = STATE_IN_TAG; $index += strlen(TAG_OPEN); continue; } if (isText($string, $index) && $state = STATE_IN_TAG) { echo $index, ' ', $string[$index], PHP_EOL; } if (isCloseTag($string, $index)) { $state = STATE_TEXT; $index += strlen(TAG_CLOSE); continue; } }

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.0150.00018.18
8.3.50.0080.00722.11
8.3.40.0170.00318.79
8.3.30.0070.00719.07
8.3.20.0040.00420.39
8.3.10.0040.00423.71
8.3.00.0000.00820.75
8.2.180.0160.00716.50
8.2.170.0000.01422.96
8.2.160.0130.00020.39
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0000.00820.84
8.2.110.0030.00622.08
8.2.100.0060.00619.54
8.2.90.0000.00819.19
8.2.80.0000.00917.97
8.2.70.0000.00817.75
8.2.60.0040.00418.16
8.2.50.0090.00018.07
8.2.40.0080.00021.18
8.2.30.0030.00518.34
8.2.20.0000.00817.88
8.2.10.0040.00418.22
8.2.00.0000.00817.75
8.1.280.0140.00025.92
8.1.270.0080.00023.79
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0040.00423.81
8.1.230.0090.00319.20
8.1.220.0060.00317.80
8.1.210.0030.00518.77
8.1.200.0090.00017.36
8.1.190.0030.00517.22
8.1.180.0040.00418.10
8.1.170.0030.00618.58
8.1.160.0000.00822.14
8.1.150.0000.00818.65
8.1.140.0000.00717.48
8.1.130.0070.00017.86
8.1.120.0000.00717.39
8.1.110.0050.00517.43
8.1.100.0050.00317.39
8.1.90.0000.00717.36
8.1.80.0040.00417.52
8.1.70.0040.00417.42
8.1.60.0060.00317.68
8.1.50.0000.00817.44
8.1.40.0040.00417.45
8.1.30.0080.00017.56
8.1.20.0030.00517.62
8.1.10.0030.00617.53
8.1.00.0060.00317.57
8.0.300.0000.00818.77
8.0.290.0040.00417.05
8.0.280.0070.00018.39
8.0.270.0000.00817.31
8.0.260.0030.00317.32
8.0.250.0030.00316.93
8.0.240.0030.00516.96
8.0.230.0030.00316.84
8.0.220.0070.00016.80
8.0.210.0000.00716.93
8.0.200.0040.00416.95
8.0.190.0030.00316.85
8.0.180.0040.00416.88
8.0.170.0040.00316.94
8.0.160.0000.00716.83
8.0.150.0040.00416.89
8.0.140.0000.00816.79
8.0.130.0000.00613.30
8.0.120.0040.00416.80
8.0.110.0040.00416.81
8.0.100.0000.00716.96
8.0.90.0000.00816.77
8.0.80.0040.01216.96
8.0.70.0040.00416.98
8.0.60.0040.00416.78
8.0.50.0040.00416.93
8.0.30.0130.00617.24
8.0.20.0160.00517.40
8.0.10.0040.00416.95
8.0.00.0100.00716.99
7.4.330.0000.00515.09
7.4.320.0070.00016.63
7.4.300.0000.00616.66
7.4.290.0030.00316.51
7.4.280.0040.00416.47
7.4.270.0030.00516.51
7.4.260.0000.00716.62
7.4.250.0000.00816.56
7.4.240.0050.00216.64
7.4.230.0030.00616.61
7.4.220.0120.00616.63
7.4.210.0030.01116.55
7.4.200.0070.00016.73
7.4.190.0030.00416.50
7.4.160.0030.01216.52
7.4.150.0090.00917.40
7.4.140.0110.00917.86
7.4.130.0110.00616.59
7.4.120.0090.00916.63
7.4.110.0140.00316.49
7.4.100.0080.01216.33
7.4.90.0150.00316.60
7.4.80.0070.01019.39
7.4.70.0150.00316.58
7.4.60.0090.00916.50
7.4.50.0030.00316.16
7.4.40.0040.01316.52
7.4.30.0040.01716.56
7.4.00.0100.00314.88
7.3.330.0030.00313.24
7.3.320.0030.00313.19
7.3.310.0040.00316.29
7.3.300.0070.00016.25
7.3.290.0060.00916.29
7.3.280.0100.00716.35
7.3.270.0130.00417.40
7.3.260.0040.01216.66
7.3.250.0090.00916.62
7.3.240.0150.00916.59
7.3.230.0140.00316.43
7.3.210.0100.01316.59
7.3.200.0030.01319.39
7.3.190.0170.00616.66
7.3.180.0030.01216.23
7.3.170.0060.00916.65
7.3.160.0070.00716.47
7.3.120.0040.01114.83
7.2.330.0150.00916.38
7.2.320.0130.00416.87
7.2.310.0000.01816.52
7.2.300.0060.01416.52
7.2.290.0180.00416.75
7.2.00.0000.01119.55
7.1.100.0100.00718.18
7.1.70.0000.00716.93
7.1.60.0100.01419.46
7.1.50.0100.00317.02
7.1.00.0200.05722.46
7.0.200.0030.00616.74
7.0.140.0070.07022.09
7.0.60.0130.07719.88
7.0.50.0030.04017.89
7.0.40.0030.07720.18
7.0.30.0530.06720.16
7.0.20.0330.08320.10
7.0.10.0030.08320.09
7.0.00.0070.05720.20
5.6.210.0170.06320.68
5.6.200.0100.08018.14
5.6.190.0070.05020.48
5.6.180.0330.06720.77
5.6.170.0230.07720.62
5.6.160.0070.04020.49
5.6.150.0100.06718.17
5.6.140.0070.06018.15
5.6.130.0070.03718.28
5.6.120.0030.04021.04
5.6.110.0070.07721.13
5.6.100.0100.07321.00
5.6.90.0130.08321.02
5.6.80.0100.08020.32
5.6.70.4070.03320.39
5.5.350.0170.07720.35
5.5.340.0070.07017.95
5.5.330.0100.08320.14
5.5.320.0530.06720.56
5.5.310.0070.04720.39
5.5.300.0130.06017.98
5.5.290.0070.08718.01
5.5.280.0070.08020.98
5.5.270.0100.08320.78
5.5.260.0000.08320.86
5.5.250.0030.06720.68
5.5.240.0300.06320.09
5.4.450.0700.06019.50
5.4.440.0200.07019.34
5.4.430.0170.05719.63
5.4.420.0670.00019.42
5.4.410.0170.05019.03
5.4.400.0270.07018.77
5.4.390.0230.05718.58
5.4.380.0000.06018.78
5.4.370.0070.05318.60
5.4.360.0100.05318.74
5.4.350.0090.03712.03
5.4.340.0100.03612.03
5.4.320.0110.03912.52
5.4.310.0090.04112.52
5.4.300.0060.03812.52
5.4.290.0060.03912.51
5.4.280.0070.04212.41
5.4.270.0090.03512.41
5.4.260.0070.03812.41
5.4.250.0090.04512.41
5.4.240.0070.04912.41
5.4.230.0080.05012.41
5.4.220.0160.03912.41
5.4.210.0070.03712.40
5.4.200.0060.04412.41
5.4.190.0090.04312.40
5.4.180.0060.04312.40
5.4.170.0080.04912.41
5.4.160.0090.04312.40
5.4.150.0110.04212.40
5.4.140.0100.09912.08
5.4.130.0140.04712.07
5.4.120.0100.05212.03
5.4.110.0100.05212.03
5.4.100.0110.04812.02
5.4.90.0120.05112.03
5.4.80.0060.05512.03
5.4.70.0080.03412.02
5.4.60.0120.03012.02
5.4.50.0070.03812.02
5.4.40.0090.03312.01
5.4.30.0050.03912.01
5.4.20.0080.04512.00
5.4.10.0090.04912.01
5.4.00.0040.05311.50
5.3.290.0070.04312.80
5.3.280.0060.05312.70
5.3.270.0090.05512.73
5.3.260.0050.04712.72
5.3.250.0070.03812.72
5.3.240.0070.03912.72
5.3.230.0050.04112.71
5.3.220.0060.04012.68
5.3.210.0050.04312.68
5.3.200.0090.04912.68
5.3.190.0070.05512.67
5.3.180.0070.05712.68
5.3.170.0070.05712.67
5.3.160.0090.05512.67
5.3.150.0140.05312.67
5.3.140.0060.06112.66
5.3.130.0120.05912.66
5.3.120.0150.05412.65
5.3.110.0070.06312.66
5.3.100.0110.05112.13
5.3.90.0060.04812.12
5.3.80.0070.03712.11
5.3.70.0040.03912.11
5.3.60.0050.03912.09
5.3.50.0040.03912.04
5.3.40.0060.03812.04
5.3.30.0040.03812.00
5.3.20.0060.03611.79
5.3.10.0090.04111.74
5.3.00.0060.04011.73
5.2.170.0050.0319.24
5.2.160.0040.0329.24
5.2.150.0050.0349.24
5.2.140.0060.0309.24
5.2.130.0050.0309.20
5.2.120.0010.0349.20
5.2.110.0040.0329.20
5.2.100.0070.0339.19
5.2.90.0070.0479.19
5.2.80.0080.0439.19
5.2.70.0090.0329.18
5.2.60.0050.0329.15
5.2.50.0070.0299.12
5.2.40.0060.0309.09
5.2.30.0070.0399.06
5.2.20.0050.0369.05
5.2.10.0080.0358.96
5.2.00.0090.0408.82
5.1.60.0100.0318.10
5.1.50.0120.0268.10
5.1.40.0070.0298.08
5.1.30.0060.0368.43
5.1.20.0050.0318.45
5.1.10.0060.0268.18
5.1.00.0080.0298.18
5.0.50.0060.0206.66
5.0.40.0050.0206.52
5.0.30.0040.0326.34
5.0.20.0020.0216.30
5.0.10.0020.0216.28
5.0.00.0040.0326.28
4.4.90.0040.0154.78
4.4.80.0050.0174.75
4.4.70.0080.0164.76
4.4.60.0070.0174.75
4.4.50.0040.0214.77
4.4.40.0030.0334.71
4.4.30.0030.0244.76
4.4.20.0090.0354.84
4.4.10.0050.0264.84
4.4.00.0060.0334.76
4.3.110.0080.0204.67
4.3.100.0060.0214.66
4.3.90.0010.0224.63
4.3.80.0040.0314.58
4.3.70.0060.0314.63
4.3.60.0030.0244.63
4.3.50.0060.0204.63
4.3.40.0040.0334.54
4.3.30.0050.0223.33
4.3.20.0020.0213.31
4.3.10.0040.0203.27
4.3.00.0070.0236.37

preferences:
44.9 ms | 400 KiB | 5 Q