3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IDN { // adapt bias for punycode algorithm private static function punyAdapt( $delta, $numpoints, $firsttime ) { $delta = $firsttime ? $delta / 700 : $delta / 2; $delta += $delta / $numpoints; for ($k = 0; $delta > 455; $k += 36) $delta = intval($delta / 35); return $k + (36 * $delta) / ($delta + 38); } // translate character to punycode number private static function decodeDigit($cp) { $cp = strtolower($cp); if ($cp >= 'a' && $cp <= 'z') return ord($cp) - ord('a'); elseif ($cp >= '0' && $cp <= '9') return ord($cp) - ord('0')+26; } // make utf8 string from unicode codepoint number private static function utf8($cp) { if ($cp < 128) return chr($cp); if ($cp < 2048) return chr(192+($cp >> 6)).chr(128+($cp & 63)); if ($cp < 65536) return chr(224+($cp >> 12)). chr(128+(($cp >> 6) & 63)). chr(128+($cp & 63)); if ($cp < 2097152) return chr(240+($cp >> 18)). chr(128+(($cp >> 12) & 63)). chr(128+(($cp >> 6) & 63)). chr(128+($cp & 63)); // it should never get here } // main decoding function private static function decodePart($input) { if (substr($input,0,4) != "xn--") // prefix check... return $input; $input = substr($input,4); // discard prefix $a = explode("-",$input); if (count($a) > 1) { $input = str_split(array_pop($a)); $output = str_split(implode("-",$a)); } else { $output = array(); $input = str_split($input); } $n = 128; $i = 0; $bias = 72; // init punycode vars while (!empty($input)) { $oldi = $i; $w = 1; for ($k = 36;;$k += 36) { $digit = IDN::decodeDigit(array_shift($input)); $i += $digit * $w; if ($k <= $bias) $t = 1; elseif ($k >= $bias + 26) $t = 26; else $t = $k - $bias; if ($digit < $t) break; $w *= intval(36 - $t); } $bias = IDN::punyAdapt( $i-$oldi, count($output)+1, $oldi == 0 ); $n += intval($i / (count($output) + 1)); $i %= count($output) + 1; array_splice($output,$i,0,array(IDN::utf8($n))); $i++; } return implode("",$output); } public static function decodeIDN($name) { // split it, parse it and put it back together return implode( ".", array_map("IDN::decodePart",explode(".",$name)) ); } } echo IDN::decodeIDN("xn---with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n");

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.0000.01418.65
8.3.50.0120.00721.27
8.3.40.0090.00618.96
8.3.30.0180.00319.04
8.3.20.0050.00320.21
8.3.10.0050.00322.09
8.3.00.0080.00022.42
8.2.180.0040.01116.63
8.2.170.0070.00722.96
8.2.160.0030.01019.00
8.2.150.0050.00324.18
8.2.140.0030.00524.66
8.2.130.0110.00726.16
8.2.120.0030.00717.80
8.2.110.0030.00620.39
8.2.100.0110.00017.97
8.2.90.0000.00819.35
8.2.80.0030.00617.97
8.2.70.0080.00017.62
8.2.60.0000.00818.05
8.2.50.0080.00018.07
8.2.40.0000.00718.20
8.2.30.0050.00218.25
8.2.20.0080.00017.96
8.2.10.0030.00717.82
8.2.00.0090.00017.88
8.1.280.0100.01025.92
8.1.270.0030.00620.40
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0100.00023.87
8.1.230.0060.00622.69
8.1.220.0040.00417.78
8.1.210.0050.00318.77
8.1.200.0030.00717.35
8.1.190.0050.00317.53
8.1.180.0040.00418.86
8.1.170.0050.00318.50
8.1.160.0000.00722.19
8.1.150.0030.00718.73
8.1.140.0030.00617.54
8.1.130.0000.00717.78
8.1.120.0000.00717.40
8.1.110.0040.00417.51
8.1.100.0050.00217.46
8.1.90.0000.00717.39
8.1.80.0040.00417.39
8.1.70.0040.00417.41
8.1.60.0040.00417.48
8.1.50.0080.00017.56
8.1.40.0040.00417.56
8.1.30.0000.00817.66
8.1.20.0050.00317.66
8.1.10.0050.00317.63
8.1.00.0000.00917.54
8.0.300.0000.00718.77
8.0.290.0040.00417.04
8.0.280.0070.00018.54
8.0.270.0000.00717.28
8.0.260.0030.00316.95
8.0.250.0000.00717.10
8.0.240.0030.00616.93
8.0.230.0070.00017.05
8.0.220.0000.00717.05
8.0.210.0000.00716.98
8.0.200.0030.00317.01
8.0.190.0000.00816.95
8.0.180.0040.00417.00
8.0.170.0070.00017.06
8.0.160.0000.00817.05
8.0.150.0030.00516.85
8.0.140.0040.00416.90
8.0.130.0060.00013.47
8.0.120.0000.00716.95
8.0.110.0000.00816.89
8.0.100.0080.00016.80
8.0.90.0020.00516.99
8.0.80.0060.01316.95
8.0.70.0040.00417.00
8.0.60.0080.00016.96
8.0.50.0030.00616.86
8.0.30.0090.01217.23
8.0.20.0080.01417.41
8.0.10.0050.00217.07
8.0.00.0050.01316.76
7.4.330.0030.00315.00
7.4.320.0060.00016.62
7.4.300.0040.00416.45
7.4.290.0040.00416.65
7.4.280.0040.00416.47
7.4.270.0030.00316.57
7.4.260.0030.00616.61
7.4.250.0070.00016.62
7.4.240.0020.00516.64
7.4.230.0050.00316.46
7.4.220.0060.01216.55
7.4.210.0120.00416.60
7.4.200.0050.00216.69
7.4.190.0040.00416.81
7.4.160.0060.01316.46
7.4.150.0070.01117.40
7.4.140.0140.00717.86
7.4.130.0110.00716.71
7.4.120.0080.01016.66
7.4.110.0090.00916.63
7.4.100.0110.00716.60
7.4.90.0070.01016.55
7.4.80.0030.01519.39
7.4.70.0000.01716.48
7.4.60.0070.01116.51
7.4.50.0000.00516.70
7.4.40.0090.00622.77
7.4.30.0100.00716.52
7.4.00.0080.00914.98
7.3.330.0000.00513.40
7.3.320.0000.00613.29
7.3.310.0080.00016.52
7.3.300.0070.00016.39
7.3.290.0100.01016.45
7.3.280.0070.00916.50
7.3.270.0110.00517.40
7.3.260.0070.01116.34
7.3.250.0110.00916.46
7.3.240.0090.01216.69
7.3.230.0030.01416.67
7.3.210.0200.00416.56
7.3.200.0140.00719.39
7.3.190.0120.00916.71
7.3.180.0060.00916.68
7.3.170.0130.00316.53
7.3.160.0060.01116.52
7.3.120.0050.01315.09
7.3.110.0070.01015.04
7.3.100.0030.01314.87
7.3.90.0060.00314.67
7.3.80.0090.00614.88
7.3.70.0030.01014.90
7.3.60.0070.00714.78
7.3.50.0060.00614.80
7.3.40.0030.01014.80
7.3.30.0060.00614.79
7.3.20.0130.00016.84
7.3.10.0040.00816.49
7.3.00.0060.00916.74
7.2.330.0140.00316.73
7.2.320.0030.01716.84
7.2.310.0090.00916.77
7.2.300.0090.00916.93
7.2.290.0080.00816.65
7.2.250.0100.01015.06
7.2.240.0140.00715.21
7.2.230.0030.00715.30
7.2.220.0070.00714.95
7.2.210.0070.00715.36
7.2.200.0030.01315.10
7.2.190.0070.00715.18
7.2.180.0000.01215.17
7.2.170.0030.00715.16
7.2.60.0180.00416.80
7.2.00.0090.00619.30
7.1.330.0000.01615.70
7.1.320.0060.00315.69
7.1.310.0040.00716.05
7.1.300.0040.00715.70
7.1.290.0060.00315.85
7.1.280.0070.00716.02
7.1.270.0090.00315.66
7.1.260.0030.00615.77
7.1.200.0000.01215.75
7.1.100.0000.01118.01
7.1.70.0030.00716.89
7.1.60.0100.01619.82
7.1.50.0100.01616.95
7.1.00.0000.04322.42
7.0.200.0000.00816.48
7.0.140.0130.06322.02
7.0.100.0170.07019.90
7.0.90.0200.06719.94
7.0.80.0070.08719.86
7.0.70.0200.07319.88
7.0.60.0070.04320.04
7.0.50.0430.06320.31
7.0.40.0070.06020.03
7.0.30.0070.07020.08
7.0.20.0070.04720.08
7.0.10.0100.06319.97
7.0.00.0270.06320.04
5.6.280.0100.07021.02
5.6.250.0170.07720.57
5.6.240.0100.08020.67
5.6.230.0200.07720.50
5.6.220.0170.05020.57
5.6.210.0070.04020.64
5.6.200.0030.07321.12
5.6.190.0070.04321.00
5.6.180.0130.06721.14
5.6.170.0070.08321.02
5.6.160.0170.06021.06
5.6.150.0000.07721.08
5.6.140.0070.06021.02
5.6.130.0000.07320.97
5.6.120.0170.07321.05
5.6.110.0100.07021.03
5.6.100.0200.04021.07
5.6.90.0100.07021.09
5.6.80.0130.07720.30
5.6.70.0130.07320.52
5.6.60.0030.05020.35
5.6.50.0070.07020.31
5.6.40.0070.07720.29
5.6.30.0130.06720.27
5.6.20.0070.07720.41
5.6.10.0100.07320.38
5.6.00.0100.08020.34
5.5.380.0070.06720.34
5.5.370.0070.04320.37
5.5.360.0130.07020.35
5.5.350.0070.05020.40
5.5.340.0030.08320.87
5.5.330.0130.06720.85
5.5.320.0170.07020.82
5.5.310.0070.07720.71
5.5.300.0070.04320.89
5.5.290.0000.04720.76
5.5.280.0130.03020.61
5.5.270.0030.08720.89
5.5.260.0070.07020.86
5.5.250.0130.07320.71
5.5.240.0000.07720.29
5.5.230.0070.08320.21
5.5.220.0070.08020.18
5.5.210.0130.07320.13
5.5.200.0100.07320.22
5.5.190.0030.05720.05
5.5.180.0070.08020.20
5.5.160.0000.08020.16
5.5.150.0100.08020.08
5.5.140.0030.07320.17
5.5.130.0030.07719.93
5.5.120.0030.04320.16
5.5.110.0130.07020.23
5.5.100.0030.07320.11
5.5.90.0100.07320.02
5.5.80.0130.06319.98
5.5.70.0030.04720.13
5.5.60.0130.07020.03
5.5.50.0070.08020.11
5.5.40.0100.06320.00
5.5.30.0030.07020.13
5.5.20.0070.06019.97
5.5.10.0070.07720.02
5.5.00.0130.05720.00
5.4.450.0070.03719.46
5.4.440.0100.05019.55
5.4.430.0100.07319.45
5.4.420.0170.07019.20
5.4.410.0070.06719.34
5.4.400.0030.06719.21
5.4.390.0130.07719.09
5.4.380.0170.06718.85
5.4.370.0030.04019.04
5.4.360.0130.07019.25
5.4.350.0170.06719.18
5.4.340.0000.07319.03
5.4.320.0100.07018.90
5.4.310.0070.07718.90
5.4.300.0000.08019.12
5.4.290.0070.04018.86
5.4.280.0070.06719.02
5.4.270.0100.05318.85
5.4.260.0130.05319.02
5.4.250.0000.08019.08
5.4.240.0130.03319.02
5.4.230.0030.08019.02
5.4.220.0130.06019.11
5.4.210.0100.06719.15
5.4.200.0030.04719.12
5.4.190.0070.07019.04
5.4.180.0070.07019.09
5.4.170.0030.07718.84
5.4.160.0000.07719.07
5.4.150.0070.04318.82
5.4.140.0030.07716.41
5.4.130.0100.06716.36
5.4.120.0030.05016.42
5.4.110.0070.06016.52
5.4.100.0070.07016.52
5.4.90.0130.03316.50
5.4.80.0100.06016.50
5.4.70.0100.07316.28
5.4.60.0130.06716.42
5.4.50.0100.05316.38
5.4.40.0070.07316.39
5.4.30.0000.06716.27
5.4.20.0030.07316.49
5.4.10.0100.07016.43
5.4.00.0070.04315.82
5.3.290.0030.07014.76
5.3.280.0070.06014.63
5.3.270.0030.08314.71
5.3.260.0000.08314.77
5.3.250.0070.07714.57
5.3.240.0030.08014.77
5.3.230.0100.07714.70
5.3.220.0130.07014.68
5.3.210.0070.06714.62
5.3.200.0100.07314.58
5.3.190.0170.06714.64
5.3.180.0100.07314.66
5.3.170.0100.04014.71
5.3.160.0070.07014.57
5.3.150.0030.07714.61
5.3.140.0070.07014.53
5.3.130.0100.05014.72
5.3.120.0030.07014.57
5.3.110.0000.07714.73
5.3.100.0070.04314.00
5.3.90.0030.07314.08
5.3.80.0030.08013.98
5.3.70.0100.07314.08
5.3.60.0130.05714.18
5.3.50.0130.05713.87
5.3.40.0070.05013.91
5.3.30.0130.05714.00
5.3.20.0030.07713.73
5.3.10.0030.06013.72
5.3.00.0100.06313.70
5.2.170.0070.03311.25
5.2.160.0070.05711.30
5.2.150.0000.05711.22
5.2.140.0030.05011.20
5.2.130.0070.06011.06
5.2.120.0130.05711.22
5.2.110.0000.04711.18
5.2.100.0070.06011.21
5.2.90.0100.05711.21
5.2.80.0030.05010.99
5.2.70.0030.05711.03
5.2.60.0100.05711.17
5.2.50.0070.05311.16
5.2.40.0030.05711.11
5.2.30.0030.06711.07
5.2.20.0030.05310.97
5.2.10.0070.05310.92
5.2.00.0000.05010.87
5.1.60.0070.04710.12
5.1.50.0000.03710.04
5.1.40.0000.05310.01
5.1.30.0000.05710.24
5.1.20.0070.04010.46
5.1.10.0070.0239.79
5.1.00.0070.0239.79
5.0.50.0030.0379.08
5.0.40.0030.0409.08
5.0.30.0030.0509.08
5.0.20.0000.0309.08
5.0.10.0000.0339.08
5.0.00.0000.0609.08
4.4.90.0030.0209.08
4.4.80.0000.0409.08
4.4.70.0000.0379.08
4.4.60.0030.0379.08
4.4.50.0070.0339.08
4.4.40.0000.0379.08
4.4.30.0030.0339.08
4.4.20.0030.0339.08
4.4.10.0070.0209.08
4.4.00.0070.0239.08
4.3.110.0030.0139.08
4.3.100.0070.0239.08
4.3.90.0030.0279.08
4.3.80.0000.0509.08
4.3.70.0070.0279.08
4.3.60.0030.0179.08
4.3.50.0100.0309.08
4.3.40.0000.0579.08
4.3.30.0030.0379.08
4.3.20.0030.0339.08
4.3.10.0070.0309.08
4.3.00.0000.0279.08

preferences:
40.74 ms | 401 KiB | 5 Q