3v4l.org

run code in 300+ PHP versions simultaneously
<?php function high($input) { // Initialize: Convert the string to lowercase, and generate an array of the alphabet $input = strtolower($input); $alphabet = range('a', 'z'); $values = array_flip($alphabet); // Split the words into an array, and declare initial scores $words = explode(" ", $input); $highestScore = null; $highestIndex = null; // Iterate over each word foreach($words as $k=>$w) { // Calculate the score of the current word // The score is the position of the flipped alphabet array, or 0 if its not in the lsit $score = array_sum(array_map(function($v) use ($values) { return $values[$v] ?? 0; }, str_split($w))); // If the current score is higher than the previous highest, overwrite it if ($highestScore < $score) { $highestScore = $score; $highestIndex = $k; } } // Return the word at the index where the score was the highest // If there were no scores (if $input is empty), return a default message return $words[$highestIndex] ?? 'N/A - No words found'; } var_dump(high('man i need a taxi up to ubud'));

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.0100.01016.38
8.3.50.0090.01516.36
8.3.40.0100.01022.03
8.3.30.0040.01118.76
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0000.00726.16
8.2.180.0160.00625.92
8.2.170.0120.00318.96
8.2.160.0060.00922.96
8.2.150.0030.00525.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.04
8.2.110.0080.00020.51
8.2.100.0000.01217.72
8.2.90.0090.00017.63
8.2.80.0060.00318.76
8.2.70.0050.00318.05
8.2.60.0060.00317.86
8.2.50.0030.00518.10
8.2.40.0070.00019.33
8.2.30.0070.00019.40
8.2.20.0080.00018.09
8.2.10.0000.00719.40
8.2.00.0040.00619.43
8.1.270.0140.00623.96
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0150.00723.90
8.1.230.0080.00320.85
8.1.220.0040.00417.78
8.1.210.0000.00818.77
8.1.200.0030.00617.36
8.1.190.0030.00617.23
8.1.180.0050.00318.10
8.1.170.0050.00318.66
8.1.160.0060.00319.04
8.1.150.0000.00918.82
8.1.140.0000.00818.80
8.1.130.0040.00420.33
8.1.120.0040.00317.41
8.1.110.0030.00617.34
8.1.100.0050.00217.51
8.1.90.0000.00717.55
8.1.80.0040.00417.47
8.1.70.0070.00017.42
8.1.60.0040.00417.66
8.1.50.0000.00917.62
8.1.40.0080.00017.60
8.1.30.0060.00317.64
8.1.20.0060.00317.65
8.1.10.0050.00217.62
8.1.00.0030.00817.57
8.0.300.0040.00418.77
8.0.290.0000.00716.58
8.0.280.0000.00818.50
8.0.270.0000.00716.84
8.0.260.0030.00320.25
8.0.250.0040.00317.03
8.0.240.0040.00417.02
8.0.230.0030.00316.85
8.0.220.0000.00716.83
8.0.210.0030.00316.87
8.0.200.0030.00316.96
8.0.190.0000.00816.86
8.0.180.0000.00716.91
8.0.170.0040.00416.89
8.0.160.0000.00716.80
8.0.150.0040.00416.86
8.0.140.0000.01116.84
8.0.130.0000.00513.33
8.0.120.0000.00716.83
8.0.110.0000.00716.90
8.0.100.0000.00816.89
8.0.90.0000.00716.75
8.0.80.0070.00716.91
8.0.70.0050.00317.02
8.0.60.0000.00816.73
8.0.50.0040.00416.93
8.0.30.0100.00717.24
8.0.20.0140.00917.19
8.0.10.0070.00016.92
8.0.00.0060.01417.03
7.4.330.0050.00015.55
7.4.320.0030.00316.58
7.4.300.0000.00716.61
7.4.290.0000.00716.58
7.4.280.0050.00216.51
7.4.270.0070.00016.51
7.4.260.0000.00513.36
7.4.250.0040.00416.41
7.4.240.0000.00716.55
7.4.230.0040.00416.42
7.4.220.0060.00116.47
7.4.210.0120.00816.67
7.4.200.0040.00416.32
7.4.130.0050.01616.52
7.4.120.0060.01516.69
7.4.110.0070.01016.52
7.4.100.0030.01516.61
7.4.90.0110.00716.44
7.4.80.0120.00616.33
7.4.70.0070.01016.61
7.4.60.0060.01016.52
7.4.50.0090.01416.43
7.4.40.0030.01316.61
7.4.30.0120.00616.55
7.4.20.0090.00916.45
7.4.10.0090.00916.30
7.4.00.0110.00616.66
7.3.330.0070.00016.24
7.3.320.0030.00313.35
7.3.310.0030.00316.35
7.3.300.0000.00716.38
7.3.290.0060.01016.40
7.3.260.0160.00816.37
7.3.230.0120.01216.71
7.3.220.0140.00316.57
7.3.210.0100.00616.44
7.3.200.0040.01516.37
7.3.190.0110.00616.38
7.3.180.0000.01716.55
7.3.170.0070.01016.53
7.3.160.0070.01016.35
7.3.150.0120.00616.53
7.3.140.0120.00616.38
7.3.130.0060.01016.43
7.3.120.0070.01016.41
7.3.110.0090.01216.63
7.3.100.0100.00616.41
7.3.90.0120.00616.48
7.3.80.0070.01116.51
7.3.70.0120.00616.48
7.3.60.0090.00916.38
7.3.50.0060.01016.49
7.3.40.0120.00916.39
7.3.30.0090.00916.41
7.3.20.0130.00616.29
7.3.10.0030.01416.46
7.3.00.0110.00616.66
7.2.340.0180.00016.69
7.2.330.0040.01416.68
7.2.320.0060.01216.80
7.2.310.0160.00616.76
7.2.300.0070.01016.71
7.2.290.0060.01216.59
7.2.280.0110.00816.69
7.2.270.0150.00316.73
7.2.260.0060.01116.87
7.2.250.0070.01716.81
7.2.240.0060.01216.47
7.2.230.0090.00916.79
7.2.220.0110.00716.86
7.2.210.0070.01016.45
7.2.200.0150.00316.57
7.2.190.0090.00916.76
7.2.180.0110.00716.80
7.2.170.0180.00316.55
7.2.160.0060.01216.63
7.2.150.0090.00916.75
7.2.140.0090.01216.66
7.2.130.0210.00316.68
7.2.120.0310.01516.75
7.2.110.0140.00516.60
7.2.100.0080.01116.76
7.2.90.0050.02016.71
7.2.80.0110.00716.57
7.2.70.0000.01816.71
7.2.60.0120.00916.57
7.2.50.0000.02116.69
7.2.40.0060.01216.79
7.2.30.0140.00316.77
7.2.20.0170.00016.66
7.2.10.0160.00016.68
7.2.00.0070.01016.68

preferences:
69.3 ms | 400 KiB | 5 Q