3v4l.org

run code in 300+ PHP versions simultaneously
<?php $alphabet = 'acdegilmnoprstuw'; // test data $hash = 680131659347; $string = 'leepadg'; $task_hash = 696005871397; echo sprintf('Hash of string «%s» is «%s».', $string, get_hash($alphabet, $string)) , PHP_EOL , sprintf('String of hash «%s» is «%s».', $hash, unhash($alphabet, $hash)) , PHP_EOL , sprintf('Solution for hash «%s» is «%s».', $task_hash, unhash($alphabet, $task_hash)) ; function get_hash($alphabet, $string) { $h = 7; $len = strlen($string); for($i = 0; $i < $len; $i++) { $h = ($h * 37 + strpos($alphabet, $string[$i])); } return $h; } function unhash($alphabet, $hash) { $result = ''; $len = strlen($alphabet); while ($hash > 7) { for ($i = 0; $i < $len; $i++) { $newres = ($hash - $i) / 37; if (is_int($newres)) { $result .= $alphabet[$i]; $hash = $newres; break; } } } return strrev($result); }

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.50
8.3.50.0110.00721.95
8.3.40.0120.00618.79
8.3.30.0070.00719.18
8.3.20.0040.00420.42
8.3.10.0060.00321.67
8.3.00.0080.00021.02
8.2.180.0160.00316.50
8.2.170.0070.00722.96
8.2.160.0030.01322.08
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0060.00319.78
8.2.110.0040.00420.57
8.2.100.0060.00618.22
8.2.90.0040.00419.22
8.2.80.0040.00417.97
8.2.70.0030.00717.63
8.2.60.0030.00617.93
8.2.50.0060.00318.07
8.2.40.0000.00820.07
8.2.30.0080.00018.14
8.2.20.0050.00317.78
8.2.10.0050.00318.15
8.2.00.0000.00717.70
8.1.280.0100.00725.92
8.1.270.0060.00320.68
8.1.260.0080.00026.35
8.1.250.0030.00728.09
8.1.240.0050.00523.71
8.1.230.0070.00318.97
8.1.220.0080.00017.78
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0040.00417.23
8.1.180.0000.00918.10
8.1.170.0000.00718.58
8.1.160.0000.00821.89
8.1.150.0060.00318.87
8.1.140.0030.00619.21
8.1.130.0030.00317.89
8.1.120.0040.00417.36
8.1.110.0040.00417.26
8.1.100.0040.00417.33
8.1.90.0000.00717.29
8.1.80.0020.00517.29
8.1.70.0070.00017.31
8.1.60.0040.00417.52
8.1.50.0000.00817.56
8.1.40.0030.00617.51
8.1.30.0030.00617.68
8.1.20.0050.00317.68
8.1.10.0030.00617.57
8.1.00.0030.00717.60
8.0.300.0080.00018.77
8.0.290.0070.00016.75
8.0.280.0000.00718.39
8.0.270.0030.00317.20
8.0.260.0030.00617.29
8.0.250.0030.00317.00
8.0.240.0030.00317.02
8.0.230.0030.00316.95
8.0.220.0040.00416.85
8.0.210.0000.00716.88
8.0.200.0000.00716.92
8.0.190.0070.00016.93
8.0.180.0000.00716.87
8.0.170.0040.00416.90
8.0.160.0000.00716.81
8.0.150.0000.00816.69
8.0.140.0000.00816.86
8.0.130.0030.00313.32
8.0.120.0080.00016.71
8.0.110.0060.00316.84
8.0.100.0040.00416.92
8.0.90.0030.00616.73
8.0.80.0030.01316.84
8.0.70.0070.00016.72
8.0.60.0040.00416.77
8.0.50.0000.00816.72
8.0.30.0120.01316.94
8.0.20.0170.00717.40
8.0.10.0050.00316.89
8.0.00.0090.00916.93
7.4.330.0030.00315.03
7.4.320.0060.00016.48
7.4.300.0070.00016.62
7.4.290.0040.00416.54
7.4.280.0000.00716.61
7.4.270.0000.00616.46
7.4.260.0040.00416.60
7.4.250.0050.00316.48
7.4.240.0020.00616.57
7.4.230.0000.00716.64
7.4.220.0090.01316.48
7.4.210.0030.01216.65
7.4.200.0040.00416.65
7.4.160.0080.00816.43
7.4.150.0080.01217.40
7.4.140.0110.01717.86
7.4.130.0090.00816.44
7.4.120.0080.01116.56
7.4.110.0140.00316.57
7.4.100.0100.01416.45
7.4.90.0100.00616.35
7.4.80.0100.01019.39
7.4.70.0070.01016.50
7.4.60.0110.00616.55
7.4.50.0050.00516.61
7.4.40.0030.01416.59
7.4.30.0170.00816.55
7.4.00.0030.01314.90
7.3.330.0020.00213.41
7.3.320.0090.00613.34
7.3.310.0040.00416.44
7.3.300.0030.00316.32
7.3.290.0110.00516.44
7.3.280.0130.00716.38
7.3.270.0120.01217.40
7.3.260.0090.00916.44
7.3.250.0100.00716.52
7.3.240.0060.01316.61
7.3.230.0000.01716.48
7.3.210.0130.00316.48
7.3.200.0140.00519.39
7.3.190.0100.00716.41
7.3.180.0070.01016.68
7.3.170.0100.01216.47
7.3.160.0110.00916.50
7.2.330.0130.00516.82
7.2.320.0000.01716.54
7.2.310.0090.01216.74
7.2.300.0130.01016.89
7.2.290.0120.00616.68
7.2.60.0100.00316.77
7.2.00.0080.00419.32
7.1.200.0000.01015.69
7.1.100.0060.00618.14
7.1.70.0040.01117.34
7.1.60.0040.01819.46
7.1.50.0100.01316.66
7.1.00.0070.07322.56
7.0.200.0120.00016.70
7.0.140.0000.05022.13
7.0.70.4830.04319.91
7.0.60.0130.06020.09
7.0.50.0100.08017.89
7.0.40.0130.08020.02
7.0.30.0170.08720.30
7.0.20.0300.07720.20
7.0.10.0330.07020.05
7.0.00.0070.07320.18
5.6.280.0000.07721.16
5.6.210.0100.08020.66
5.6.200.0070.06718.21
5.6.190.0100.06720.41
5.6.180.0300.07720.36
5.6.170.0130.06720.41
5.6.160.0070.07320.43
5.6.150.0030.05318.29
5.6.140.0100.06718.29
5.6.130.0130.07318.24
5.6.120.0070.08021.03
5.6.110.0030.06721.11
5.6.100.0130.06021.02
5.6.90.0070.08320.85
5.6.80.0070.04320.45
5.6.70.0230.07320.38
5.5.350.0100.08320.34
5.5.340.0100.08317.97
5.5.330.0070.09020.26
5.5.320.0000.05320.41
5.5.310.0230.07720.34
5.5.300.0030.09018.08
5.5.290.0100.05017.95
5.5.280.0000.04320.86
5.5.270.0000.09320.66
5.5.260.0070.08320.77
5.5.250.0030.04020.58
5.5.240.0070.08020.29
5.4.450.0270.05319.21
5.4.440.0630.05719.61
5.4.430.0200.05319.38
5.4.420.0270.04319.57
5.4.410.0230.05019.34
5.4.400.0130.06319.28
5.4.390.0200.05318.79
5.4.380.0170.05718.78
5.4.370.0300.06718.51
5.4.360.0300.06318.61
5.4.350.0200.07718.63
5.4.340.0270.07018.51
5.4.320.0270.05318.55
5.4.310.0300.05318.50
5.4.300.0230.05718.62
5.4.290.0270.04318.73
5.4.280.0200.06718.72
5.4.270.0100.06318.83
5.4.260.0170.05718.73
5.4.250.0230.05718.84
5.4.240.0300.06018.57
5.4.230.0170.07018.73
5.4.220.0200.06718.77
5.4.210.0270.06318.79
5.4.200.0270.06016.63
5.4.190.0230.06318.52
5.4.180.0200.07018.48
5.4.170.0230.05018.77
5.4.160.0200.05318.45
5.4.150.0200.05318.74
5.4.140.0200.06016.30
5.4.130.0300.03716.28
5.4.120.0070.06716.34
5.4.110.0270.05016.25
5.4.100.0300.04716.29
5.4.90.0230.04716.33
5.4.80.0270.04016.16
5.4.70.0130.05716.41
5.4.60.0300.04316.19
5.4.50.0170.07016.42
5.4.40.0170.06316.32
5.4.30.0030.06716.22
5.4.20.0170.05716.21
5.4.10.0200.05016.42
5.4.00.0130.05715.73
5.3.290.0270.05314.81
5.3.280.0270.04714.64
5.3.270.0170.05714.64
5.3.260.0270.04714.80
5.3.250.0170.05314.65
5.3.240.0300.06314.84
5.3.230.0230.07014.64
5.3.220.0170.05714.71
5.3.210.0230.06014.58
5.3.200.0300.04714.60
5.3.190.0370.05014.55
5.3.180.0070.06714.70
5.3.170.0070.06314.61
5.3.160.0300.04314.61
5.3.150.0200.05314.63
5.3.140.0170.06014.61
5.3.130.0100.06014.68
5.3.120.0170.05714.72
5.3.110.0130.06014.74
5.3.100.0200.06314.27
5.3.90.0230.06314.05
5.3.80.0200.06314.14
5.3.70.0200.06314.20
5.3.60.0300.05314.03
5.3.50.0270.04314.06
5.3.40.0100.06013.94
5.3.30.0200.05013.92
5.3.20.0230.04713.82
5.3.10.0170.05013.87
5.3.00.0200.05313.64
5.2.170.0130.04711.18
5.2.160.0200.03711.17
5.2.150.0130.04311.36
5.2.140.0200.04011.18
5.2.130.0130.04311.21
5.2.120.0100.04711.15
5.2.110.0070.05011.16
5.2.100.0200.04011.19
5.2.90.0170.03711.15
5.2.80.0230.03311.21
5.2.70.0100.04711.14
5.2.60.0100.05011.17
5.2.50.0100.04711.07
5.2.40.0130.04711.04
5.2.30.0170.04011.03
5.2.20.0100.04311.06
5.2.10.0170.03710.94
5.2.00.0130.04010.83
5.1.60.0100.03310.08
5.1.50.0100.04010.14
5.1.40.0230.03010.09
5.1.30.0170.03710.47
5.1.20.0100.03710.57
5.1.10.0200.03010.13
5.1.00.0170.03310.10
5.0.50.0070.0379.52
5.0.40.0130.0239.52
5.0.30.0130.0379.52
5.0.20.0030.0339.52
5.0.10.0100.0339.52
5.0.00.0070.0539.52
4.4.90.0100.0209.52
4.4.80.0000.0279.52
4.4.70.0100.0239.52
4.4.60.0070.0239.52
4.4.50.0100.0209.52
4.4.40.0030.0409.52
4.4.30.0030.0239.52
4.4.20.0030.0279.52
4.4.10.0070.0279.52
4.4.00.0070.0409.52
4.3.110.0070.0279.52
4.3.100.0070.0209.52
4.3.90.0100.0209.52
4.3.80.0100.0309.52
4.3.70.0070.0209.52
4.3.60.0070.0209.52
4.3.50.0000.0279.52
4.3.40.0070.0339.52
4.3.30.0070.0209.52
4.3.20.0070.0209.52
4.3.10.0030.0239.52
4.3.00.0030.0207.02

preferences:
38.45 ms | 401 KiB | 5 Q