3v4l.org

run code in 300+ PHP versions simultaneously
<?php function HacklandElection($arr = []) { $collection = []; foreach ($arr as $voter) { if (array_key_exists($voter, $collection)) { $collection[$voter] += 1; } else { $collection[$voter] = 1; } } $max = max($collection); $collection = array_keys($collection, $max); arsort($collection); return array_shift($collection); } //$mag1 = ['Alex' => 10, 'Harry' => 0, 'Michael' => 2, 'Mary' => -1]; $votes = ["Alex", "Michael", "Harry", "Dave", "Michael", "Victor", "Harry", "Alex", "Mary", "Mary"]; echo HacklandElection($votes);

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.29
8.3.50.0150.00616.63
8.3.40.0090.00918.80
8.3.30.0130.00318.88
8.3.20.0080.00018.70
8.3.10.0040.00423.66
8.3.00.0100.00019.38
8.2.180.0080.01218.16
8.2.170.0090.00922.96
8.2.160.0110.00418.96
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0040.00419.24
8.2.120.0000.00826.35
8.2.110.0060.00319.39
8.2.100.0040.00818.03
8.2.90.0040.00418.03
8.2.80.0040.00418.03
8.2.70.0000.00817.93
8.2.60.0050.00318.04
8.2.50.0000.00818.22
8.2.40.0080.00020.47
8.2.30.0040.00419.32
8.2.20.0000.00717.99
8.2.10.0040.00418.13
8.2.00.0050.00218.24
8.1.270.0070.00020.00
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0100.00023.78
8.1.230.0070.00420.95
8.1.220.0040.00417.76
8.1.210.0080.00018.77
8.1.200.0000.00817.35
8.1.190.0060.00317.35
8.1.180.0030.00518.10
8.1.170.0040.00418.65
8.1.160.0040.00418.89
8.1.150.0000.00818.96
8.1.140.0000.00718.99
8.1.130.0040.00419.02
8.1.120.0000.00817.49
8.1.110.0030.00617.48
8.1.100.0050.00217.33
8.1.90.0000.00717.43
8.1.80.0000.00717.36
8.1.70.0000.00717.51
8.1.60.0000.00817.41
8.1.50.0040.00417.41
8.1.40.0000.00917.49
8.1.30.0040.00417.70
8.1.20.0060.00317.54
8.1.10.0050.00317.57
8.1.00.0040.00417.45
8.0.300.0020.00519.87
8.0.290.0040.00416.63
8.0.280.0000.00718.45
8.0.270.0000.00717.23
8.0.260.0030.00317.39
8.0.250.0070.00016.83
8.0.240.0040.00416.85
8.0.230.0000.00716.85
8.0.220.0030.00316.95
8.0.210.0000.00716.89
8.0.200.0030.00316.84
8.0.190.0030.00516.96
8.0.180.0050.00216.94
8.0.170.0060.00316.96
8.0.160.0050.00216.94
8.0.150.0000.00716.73
8.0.140.0000.00716.89
8.0.130.0050.00013.33
8.0.120.0050.00316.88
8.0.110.0050.00216.99
8.0.100.0020.00516.80
8.0.90.0000.00816.84
8.0.80.0060.01316.78
8.0.70.0080.00016.91
8.0.60.0000.00716.96
8.0.50.0070.00016.96
8.0.30.0150.00617.18
8.0.20.0110.01017.40
8.0.10.0070.00016.88
8.0.00.0090.01316.75
7.4.330.0050.00015.55
7.4.320.0030.00316.46
7.4.300.0030.00316.50
7.4.290.0060.00016.40
7.4.280.0040.00416.50
7.4.270.0030.00316.47
7.4.260.0080.00016.48
7.4.250.0040.00416.48
7.4.240.0000.00716.49
7.4.230.0070.00016.69
7.4.220.0050.00216.67
7.4.210.0080.00916.49
7.4.200.0030.00316.71
7.4.160.0110.00516.43
7.4.150.0070.01817.40
7.4.140.0100.00917.86
7.4.130.0080.01716.40
7.4.120.0130.00616.54
7.4.110.0090.00616.48
7.4.100.0060.01616.50
7.4.90.0070.01116.52
7.4.80.0210.00019.39
7.4.70.0100.00716.51
7.4.60.0070.01016.39
7.4.50.0070.01116.58
7.4.40.0100.00616.46
7.4.10.0070.01214.96
7.4.00.0090.00815.01
7.3.330.0050.00013.38
7.3.320.0000.00513.22
7.3.310.0080.00016.26
7.3.300.0000.00716.37
7.3.290.0030.00316.37
7.3.280.0120.00316.35
7.3.270.0090.00917.40
7.3.260.0080.01016.56
7.3.250.0060.01216.43
7.3.240.0100.01016.63
7.3.230.0090.00916.50
7.3.210.0030.01416.50
7.3.200.0150.00616.73
7.3.190.0060.00916.58
7.3.180.0060.00916.47
7.3.170.0120.01216.26
7.3.160.0100.00616.33
7.3.130.0050.01314.89
7.3.120.0050.01315.06
7.3.110.0080.01114.73
7.3.100.0060.00814.83
7.3.90.0050.01014.76
7.3.80.0040.00814.68
7.3.70.0060.00614.97
7.3.60.0050.00914.83
7.3.50.0050.00514.85
7.3.40.0020.01014.86
7.3.30.0020.00914.76
7.3.20.0070.00716.86
7.3.10.0120.00816.54
7.3.00.0080.00816.62
7.2.330.0140.00316.75
7.2.320.0080.00816.46
7.2.310.0140.00316.65
7.2.300.0070.01116.72
7.2.290.0090.00616.48
7.2.260.0050.01015.10
7.2.250.0060.01315.17
7.2.240.0070.00815.21
7.2.230.0050.01015.23
7.2.220.0100.00615.13
7.2.210.0110.00215.04
7.2.200.0020.01115.11
7.2.190.0050.01114.97
7.2.180.0020.01215.08
7.2.170.0050.01115.01
7.2.160.0080.00615.08
7.2.150.0060.01016.86
7.2.140.0060.01216.98
7.2.130.0080.00616.94
7.2.120.0110.00616.75
7.2.110.0080.00916.83
7.2.100.0110.00516.75
7.2.90.0080.00816.93
7.2.80.0060.01016.83
7.2.70.0070.00716.80
7.2.60.0060.00916.83
7.2.50.0080.00816.85
7.2.40.0070.00916.84
7.2.30.0080.01116.67
7.2.20.0050.01016.74
7.2.10.0070.01017.00
7.2.00.0100.00817.15
7.1.330.0050.01015.62
7.1.320.0030.00915.81
7.1.310.0070.00515.78
7.1.300.0000.01215.74
7.1.290.0040.00815.77
7.1.280.0060.00816.01
7.1.270.0070.00915.88
7.1.260.0020.01115.85
7.1.250.0100.00715.50
7.1.240.0050.00915.90
7.1.230.0050.00715.79
7.1.220.0070.00615.78
7.1.210.0050.00715.81
7.1.200.0070.00515.90
7.1.190.0060.00615.67
7.1.180.0050.00715.88
7.1.170.0080.00515.89
7.1.160.0070.00515.61
7.1.150.0090.00415.73
7.1.140.0060.00415.91
7.1.130.0090.00816.22
7.1.120.0100.00616.19
7.1.110.0130.00416.03
7.1.100.0100.00816.09
7.1.90.0110.00715.89
7.1.80.0100.00515.90
7.1.70.0100.00615.71
7.1.60.0110.00821.69
7.1.50.0240.00721.54
7.1.40.0110.01221.36
7.1.30.0200.00421.45
7.1.20.0110.01021.32
7.1.10.0100.00815.49
7.1.00.0080.01015.45
7.0.330.0030.00715.63
7.0.320.0060.00515.47
7.0.310.0030.01115.17
7.0.300.0050.00915.46
7.0.290.0050.01015.55
7.0.280.0070.00715.40
7.0.270.0080.00415.39
7.0.260.0070.00415.21
7.0.250.0030.00615.53
7.0.240.0090.00415.39
7.0.230.0070.00715.53
7.0.220.0040.00915.44
7.0.210.0020.00815.35
7.0.200.0050.00915.24
7.0.190.0060.00915.56
7.0.180.0030.00715.46
7.0.170.0030.00915.14
7.0.160.0020.01015.28
7.0.150.0060.00615.32
7.0.140.0060.00815.37
7.0.130.0060.00715.43
7.0.120.0040.01015.48
7.0.110.0070.00515.41
7.0.100.0110.00315.49
7.0.90.0100.00415.41
7.0.80.0030.00815.46
7.0.70.0030.00615.38
7.0.60.0060.00515.43
7.0.50.0080.00315.46
7.0.40.0030.00813.41
7.0.30.0050.00713.60
7.0.20.0060.00513.32
7.0.10.0090.00313.31
7.0.00.0080.00513.56
5.6.400.0030.00914.30
5.6.390.0000.01314.63
5.6.380.0060.00714.49
5.6.370.0060.00814.55
5.6.360.0060.00414.45
5.6.350.0050.01114.64
5.6.340.0060.01014.38
5.6.330.0050.00914.64
5.6.320.0050.00514.31
5.6.310.0070.00614.37
5.6.300.0060.00814.47
5.6.290.0020.01014.34
5.6.280.0070.00214.45
5.6.270.0020.01014.51
5.6.260.0030.00814.37
5.6.250.0050.00714.61
5.6.240.0080.00314.55
5.6.230.0040.00914.36
5.6.220.0080.00514.39
5.6.210.0080.00514.41
5.6.200.0050.00714.44
5.6.190.0090.00514.49
5.6.180.0070.00614.47
5.6.170.0030.01114.36
5.6.160.0050.00814.46
5.6.150.0080.00614.29
5.6.140.0050.00614.27
5.6.130.0040.00914.51
5.6.120.0070.00514.28
5.6.110.0080.00714.38
5.6.100.0080.00414.49
5.6.90.0020.00714.37
5.6.80.0020.00714.36
5.6.70.0050.00814.09
5.6.60.0030.01014.21
5.6.50.0060.00914.31
5.6.40.0060.00514.22
5.6.30.0100.00314.42
5.6.20.0040.00714.27
5.6.10.0090.00114.13
5.6.00.0030.00714.30

preferences:
51.89 ms | 400 KiB | 5 Q