3v4l.org

run code in 300+ PHP versions simultaneously
<?php function previewTotalLength($labels){ $count = mb_strlen('rfc-vote ') - 2; foreach($labels as $label){ $countEllipsis = $label['trim'] ? 1 : 0; $count += $label['length'] - $label['trim'] + $countEllipsis + 2; } return $count; } function calcTrim($labels, $largestLabelLength, $chars, $stopAtTargetLength){ foreach($labels as $i => $label){ $labels[$i]['trim'] = max((int)floor(($label['length'] - 20) / $largestLabelLength * $chars), 0); if(previewTotalLength($labels) <= $stopAtTargetLength){ $chars++; } } return $labels; } $d = "Typed Properties,PHP Attributes,Functional Interfaces,Closure from callable function,Forbid dynamic calls to scope introspection functions,Callable prototypes"; $labelsList = []; foreach(explode(",", $d) as $label){ $labelsList[] = ['label' => $label, 'length' => mb_strlen($label), 'trim' => 0]; } $largestLabelLength = 0; foreach($labelsList as $label){ if($label['length'] > $largestLabelLength){ $largestLabelLength = $label['length']; } } $strip = 2; while(previewTotalLength($labelsList) > 150){ $labelsList = calcTrim($labelsList, $largestLabelLength, $strip++, 150); } print_r($labelsList); print_r(previewTotalLength($labelsList)); // preview result echo "\n"; echo "rfc-vote "; foreach($labelsList as $label){ $b = mb_substr($label['label'], 0, $label['length'] - $label['trim']); $b .= $label['trim'] ? '…' : ''; $collect[] = $b; } echo implode(', ', $collect);

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.5.30.0100.00418.84
8.5.20.0100.00820.16
8.5.10.0120.00620.16
8.5.00.0120.00920.21
8.4.180.0140.00822.11
8.4.170.0140.00822.43
8.4.160.0110.00020.57
8.4.150.0090.00416.90
8.4.140.0110.01017.72
8.4.130.0110.00917.71
8.4.120.0120.00620.34
8.4.110.0070.00422.61
8.4.100.0080.01217.82
8.4.90.0130.00818.04
8.4.80.0070.00120.64
8.4.70.0050.00417.67
8.4.60.0100.01118.68
8.4.50.0130.00817.98
8.4.40.0130.00719.60
8.4.30.0090.00617.51
8.4.20.0130.00717.72
8.4.10.0110.01117.84
8.3.300.0160.00520.81
8.3.290.0110.01020.91
8.3.280.0120.01218.32
8.3.270.0070.01216.58
8.3.260.0140.00516.52
8.3.250.0120.00719.09
8.3.240.0090.01116.76
8.3.230.0120.00716.72
8.3.220.0090.01017.12
8.3.210.0060.00316.77
8.3.200.0060.00418.40
8.3.190.0110.00719.13
8.3.180.0130.00618.66
8.3.170.0100.00917.16
8.3.160.0120.00616.57
8.3.150.0060.00319.26
8.3.140.0060.01016.86
8.3.130.0140.00716.61
8.3.120.0080.00020.60
8.3.110.0060.00316.57
8.3.100.0100.00718.14
8.3.90.0120.00326.77
8.3.80.0000.00918.31
8.3.70.0120.00616.63
8.3.60.0150.00718.43
8.3.50.0070.00921.95
8.3.40.0140.00719.00
8.3.30.0120.00318.92
8.3.20.0060.00319.32
8.3.10.0040.00422.04
8.3.00.0080.00019.18
8.2.300.0080.01222.29
8.2.290.0140.00620.68
8.2.280.0160.00418.46
8.2.270.0160.00316.51
8.2.260.0040.00419.26
8.2.250.0040.00418.48
8.2.240.0120.00316.76
8.2.230.0040.00420.94
8.2.220.0030.00624.06
8.2.210.0110.00426.77
8.2.200.0060.00318.54
8.2.190.0180.00316.75
8.2.180.0160.00318.29
8.2.170.0040.01122.96
8.2.160.0140.00020.38
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0070.00019.39
8.2.120.0100.00326.35
8.2.110.0060.00320.52
8.2.100.0040.00819.79
8.2.90.0090.00019.32
8.2.80.0080.00017.97
8.2.70.0080.00017.75
8.2.60.0090.00018.05
8.2.50.0040.00418.10
8.2.40.0000.00822.27
8.2.30.0030.00619.46
8.2.20.0040.00417.99
8.2.10.0060.00318.32
8.2.00.0050.00318.24
8.1.340.0110.00921.68
8.1.330.0130.00618.51
8.1.320.0070.01216.41
8.1.310.0030.00516.91
8.1.300.0050.00318.46
8.1.290.0090.00030.84
8.1.280.0070.01025.92
8.1.270.0080.00024.04
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0110.00317.52
8.1.230.0030.00919.67
8.1.220.0030.00517.78
8.1.210.0030.00618.77
8.1.200.0070.00417.35
8.1.190.0000.00817.35
8.1.180.0030.00518.10
8.1.170.0050.00318.63
8.1.160.0040.00419.12
8.1.150.0020.00518.88
8.1.140.0060.00319.75
8.1.130.0000.00717.73
8.1.120.0050.00317.65
8.1.110.0040.00417.48
8.1.100.0050.00317.41
8.1.90.0030.00517.53
8.1.80.0040.00417.62
8.1.70.0000.00817.58
8.1.60.0040.00417.64
8.1.50.0030.00617.57
8.1.40.0040.00417.70
8.1.30.0040.00417.77
8.1.20.0000.00817.76
8.1.10.0000.00817.78
8.1.00.0060.00317.66
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0000.00718.62
8.0.270.0000.00717.43
8.0.260.0000.00617.34
8.0.250.0040.00716.89
8.0.240.0070.00017.12
8.0.230.0000.00817.09
8.0.220.0040.00417.08
8.0.210.0030.00316.98
8.0.200.0070.00017.16
8.0.190.0080.00017.11
8.0.180.0040.00417.02
8.0.170.0040.00417.04
8.0.160.0070.00017.04
8.0.150.0050.00317.10
8.0.140.0000.00716.94
8.0.130.0000.00613.45
8.0.120.0030.00617.05
8.0.110.0000.00817.00
8.0.100.0040.00417.01
8.0.90.0040.00417.02
8.0.80.0090.00617.09
8.0.70.0040.00417.05
8.0.60.0040.00416.90
8.0.50.0000.00717.17
8.0.30.0110.00817.12
8.0.20.0110.01217.42
8.0.10.0000.00816.95
8.0.00.0090.01516.97
7.4.330.0030.00315.26
7.4.320.0030.00316.65
7.4.300.0030.00316.68
7.4.290.0060.00616.70
7.4.280.0050.00216.61
7.4.270.0030.00316.73
7.4.260.0000.00716.62
7.4.250.0030.00316.58
7.4.240.0000.00716.52
7.4.230.0000.00816.78
7.4.220.0100.01016.68
7.4.210.0060.00916.75
7.4.200.0040.00416.61
7.4.160.0060.01116.71
7.4.150.0150.00417.40
7.4.140.0060.01117.86
7.4.130.0130.00716.63
7.4.120.0100.00716.63
7.4.110.0130.01216.60
7.4.100.0070.01416.66
7.4.90.0110.00616.49
7.4.80.0070.01019.39
7.4.70.0100.00616.69
7.4.60.0030.01316.59
7.4.50.0000.01516.73
7.4.40.0060.01316.73
7.4.30.0030.01316.43
7.4.00.0070.01015.19
7.3.330.0030.00313.41
7.3.320.0030.00313.45
7.3.310.0000.00716.48
7.3.300.0030.00516.47
7.3.290.0130.00316.43
7.3.280.0110.00716.47
7.3.270.0160.00317.40
7.3.260.0080.00916.59
7.3.250.0130.00416.50
7.3.240.0120.00816.50
7.3.230.0120.00416.73
7.3.210.0030.01316.53
7.3.200.0100.00716.54
7.3.190.0040.01116.64
7.3.180.0080.00816.61
7.3.170.0070.01016.51
7.3.160.0100.01316.75
7.2.330.0030.01416.80
7.2.320.0090.01216.88
7.2.310.0160.00916.79
7.2.300.0170.00716.55
7.2.290.0120.00416.61
7.2.60.0000.01416.91
7.2.00.0000.01119.46
7.1.200.0030.01315.96
7.1.100.0060.00918.32
7.1.70.0070.00417.23
7.1.60.0140.01119.47
7.1.00.0070.07322.35
7.0.200.0060.00616.44
7.0.60.0100.05720.02
7.0.50.1270.05320.27
7.0.40.1200.05720.33
7.0.30.1300.05720.37
7.0.20.1230.06020.40
7.0.10.1300.05320.45
7.0.00.1500.07720.28
5.6.210.0170.06020.61
5.6.200.1030.06021.10
5.6.190.1130.05321.08
5.6.180.1130.05721.04
5.6.170.1030.06021.04
5.6.160.1100.05720.93
5.6.150.1200.05321.05
5.6.140.1200.05021.06
5.6.130.1130.06321.06
5.6.120.0200.05721.08
5.6.110.0400.05721.07
5.6.100.0970.05321.05
5.6.90.1000.05721.03
5.6.80.0930.05320.52
5.6.70.0970.05020.60
5.6.60.0900.05320.44
5.6.50.0930.05320.51
5.6.40.0970.05020.42
5.6.30.0900.05720.41
5.6.20.0870.05720.43
5.6.10.1000.06020.41
5.6.00.1070.05320.39
5.5.350.0600.06020.42
5.5.340.1130.05020.89
5.5.330.1070.06020.79
5.5.320.1100.05320.86
5.5.310.1100.06320.82
5.5.300.1000.07320.76
5.5.290.1100.06320.98
5.5.280.0200.05321.04
5.5.270.0900.06020.88
5.5.260.0930.06020.93
5.5.250.0970.05720.70
5.5.240.1000.05320.41
5.5.230.0900.06020.44
5.5.220.0870.05720.19
5.5.210.1000.05720.36
5.5.200.0830.06020.24
5.5.190.1130.06020.23
5.5.180.1130.05020.20
5.5.160.1070.07720.20
5.5.150.0970.05720.32
5.5.140.1100.05320.16
5.5.130.1030.05720.23
5.5.120.1170.05020.23
5.5.110.1030.05720.19
5.5.100.1370.07020.30
5.5.90.1070.05720.19
5.5.80.0930.06020.17
5.5.70.1170.06020.03
5.5.60.1170.04720.12
5.5.50.1070.05320.17
5.5.40.0930.05020.12
5.5.30.0930.05320.11
5.5.20.0870.06720.17
5.5.10.0830.06320.07
5.5.00.0900.05320.14

preferences:
63.7 ms | 1933 KiB | 5 Q