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--Hello-Another-Way--fc4qua05auwb3674vfr0b");

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.0160.01018.43
8.3.50.0100.00921.15
8.3.40.0100.01018.97
8.3.30.0080.00819.01
8.3.20.0070.00020.32
8.3.10.0080.00021.92
8.3.00.0080.00022.49
8.2.180.0120.00616.38
8.2.170.0100.00722.96
8.2.160.0100.00319.34
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0120.00326.16
8.2.120.0070.00319.66
8.2.110.0030.00622.07
8.2.100.0040.00819.40
8.2.90.0000.00819.37
8.2.80.0030.00619.21
8.2.70.0000.00817.75
8.2.60.0040.00418.16
8.2.50.0000.00918.07
8.2.40.0040.00418.34
8.2.30.0040.00418.12
8.2.20.0000.00718.02
8.2.10.0030.00618.00
8.2.00.0040.00417.79
8.1.280.0140.00425.92
8.1.270.0060.00318.75
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00723.96
8.1.230.0070.00418.97
8.1.220.0040.00417.80
8.1.210.0000.00818.77
8.1.200.0030.00717.36
8.1.190.0000.00817.52
8.1.180.0000.00818.87
8.1.170.0080.00018.64
8.1.160.0040.00422.10
8.1.150.0000.00818.64
8.1.140.0040.00417.37
8.1.130.0000.00917.92
8.1.120.0050.00317.53
8.1.110.0000.00817.49
8.1.100.0070.00017.38
8.1.90.0040.00417.43
8.1.80.0040.00417.39
8.1.70.0040.00417.35
8.1.60.0030.00617.59
8.1.50.0060.00317.61
8.1.40.0060.00317.54
8.1.30.0060.00317.67
8.1.20.0000.00917.66
8.1.10.0060.00317.61
8.1.00.0030.00517.41
8.0.300.0070.00018.77
8.0.290.0000.00717.16
8.0.280.0000.00818.40
8.0.270.0050.00317.26
8.0.260.0040.00416.87
8.0.250.0000.00717.04
8.0.240.0030.00617.06
8.0.230.0040.00417.03
8.0.220.0000.00717.01
8.0.210.0030.00317.03
8.0.200.0030.00316.89
8.0.190.0030.00517.12
8.0.180.0030.00516.95
8.0.170.0030.00516.92
8.0.160.0040.00416.93
8.0.150.0050.00316.85
8.0.140.0000.00816.85
8.0.130.0060.00013.43
8.0.120.0070.00016.95
8.0.110.0000.00716.90
8.0.100.0000.00716.82
8.0.90.0080.00016.87
8.0.80.0030.01316.99
8.0.70.0040.00416.89
8.0.60.0060.00317.07
8.0.50.0030.00616.98
8.0.30.0100.00817.36
8.0.20.0140.00817.42
8.0.10.0050.00217.17
8.0.00.0110.00616.86
7.4.330.0050.00015.00
7.4.320.0040.00416.62
7.4.300.0000.00616.65
7.4.290.0030.00616.61
7.4.280.0070.00016.61
7.4.270.0000.00716.54
7.4.260.0040.00416.59
7.4.250.0040.00416.55
7.4.240.0030.00416.65
7.4.230.0050.00316.71
7.4.220.0120.01316.60
7.4.210.0060.00816.64
7.4.200.0040.00416.65
7.4.190.0070.00016.76
7.4.160.0060.01016.57
7.4.150.0080.00817.40
7.4.140.0090.01117.86
7.4.130.0100.01016.67
7.4.120.0090.00916.55
7.4.110.0140.00316.80
7.4.100.0130.00616.62
7.4.90.0150.00916.59
7.4.80.0060.01719.39
7.4.70.0110.00616.45
7.4.60.0060.01016.44
7.4.50.0040.00016.69
7.4.40.0090.00322.77
7.4.30.0090.00616.58
7.4.00.0100.00714.97
7.3.330.0050.00013.34
7.3.320.0040.00413.33
7.3.310.0040.00416.37
7.3.300.0070.00016.54
7.3.290.0000.01916.52
7.3.280.0070.01016.46
7.3.270.0170.00017.40
7.3.260.0080.00916.66
7.3.250.0050.01316.54
7.3.240.0040.01216.60
7.3.230.0060.01216.50
7.3.210.0140.00316.71
7.3.200.0070.01719.39
7.3.190.0090.01416.47
7.3.180.0050.01416.63
7.3.170.0090.00616.51
7.3.160.0060.01016.44
7.3.120.0100.00616.01
7.3.110.0070.00915.92
7.3.100.0080.00816.16
7.3.90.0060.00915.97
7.3.80.0030.00615.94
7.3.70.0060.01116.04
7.3.60.0080.00816.01
7.3.50.0080.00516.06
7.3.40.0050.01016.03
7.3.30.0080.00815.98
7.3.20.0070.00616.88
7.3.10.0060.01016.92
7.3.00.0050.01116.78
7.2.330.0100.00716.63
7.2.320.0140.00316.84
7.2.310.0090.01316.74
7.2.300.0110.00516.71
7.2.290.0110.00816.88
7.2.250.0120.00615.07
7.2.240.0080.00916.10
7.2.230.0040.01316.06
7.2.220.0050.00616.13
7.2.210.0080.00816.13
7.2.200.0060.00716.10
7.2.190.0100.00616.15
7.2.180.0020.01016.23
7.2.170.0050.00816.20
7.2.160.0030.00617.15
7.2.150.0100.00717.15
7.2.140.0110.00017.15
7.2.130.0060.00917.15
7.2.120.0030.01317.15
7.2.110.0060.00917.15
7.2.100.0140.00317.15
7.2.90.0110.00717.15
7.2.80.0070.00717.15
7.2.70.0000.01617.15
7.2.60.0120.00716.93
7.2.50.0040.00717.15
7.2.40.0070.01017.15
7.2.30.0110.00417.15
7.2.20.0030.01217.15
7.2.10.0090.00317.15
7.2.00.0060.00718.36
7.1.330.0090.00816.54
7.1.320.0030.00916.54
7.1.310.0030.01016.53
7.1.300.0140.00216.44
7.1.290.0090.00516.54
7.1.280.0050.01116.38
7.1.270.0070.00416.49
7.1.260.0030.01016.51
7.1.250.0130.00317.15
7.1.200.0060.00315.80
7.1.100.0030.01018.29
7.1.70.0000.00717.06
7.1.60.0040.01519.82
7.1.50.0080.01117.01
7.1.00.0030.03322.48
7.0.200.0040.00416.52
7.0.140.0030.07022.11
7.0.60.0030.05019.99
7.0.50.0000.06317.91
7.0.40.0030.07020.40
7.0.30.0400.06720.16
7.0.20.0100.04720.25
7.0.10.0130.08020.24
7.0.00.0100.08720.12
5.6.280.0070.06721.15
5.6.210.0130.07020.77
5.6.200.0030.04318.15
5.6.190.0030.08720.41
5.6.180.0300.03720.58
5.6.170.0200.04020.58
5.6.160.0070.05320.50
5.6.150.0100.04718.25
5.6.140.0070.06718.30
5.6.130.0030.08318.18
5.6.120.0070.06721.03
5.6.110.0100.08021.00
5.6.100.0130.07721.01
5.6.90.0170.07720.99
5.6.80.0070.03720.41
5.5.350.0300.07320.35
5.5.340.0070.03718.11
5.5.330.0070.08020.43
5.5.320.0200.04020.34
5.5.310.0330.06020.37
5.5.300.0030.04317.94
5.5.290.0070.06017.98
5.5.280.0000.06720.87
5.5.270.0070.08720.81
5.5.260.0100.07320.70
5.5.250.0100.08320.71
5.5.240.0070.06720.30
5.4.450.0400.08019.43
5.4.440.0270.04719.30
5.4.430.0770.03719.16
5.4.420.0400.04019.32
5.4.410.0300.03019.43
5.4.400.0600.03719.00
5.4.390.0470.04319.16
5.4.380.0300.05318.77
5.4.370.0370.05318.77
5.4.360.0230.06318.49
5.4.350.0130.07318.75
5.4.340.0270.05718.59
5.4.320.0050.03612.53
5.4.310.0060.04512.52
5.4.300.0050.04312.52
5.4.290.0050.04112.52
5.4.280.0080.04012.42
5.4.270.0040.04412.42
5.4.260.0060.04112.42
5.4.250.0100.04718.79
5.4.240.0170.04318.92
5.4.230.0000.08318.92
5.4.220.0000.06318.92
5.4.210.0030.05718.96
5.4.200.0100.05018.80
5.4.190.0030.06018.72
5.4.180.0070.05318.91
5.4.170.0130.04718.75
5.4.160.0100.05318.77
5.4.150.0100.06718.88
5.4.140.0230.05316.37
5.4.130.0070.04716.32
5.4.120.0070.06316.44
5.4.110.0100.04716.44
5.4.100.0130.06016.40
5.4.90.0200.03716.48
5.4.80.0170.05716.36
5.4.70.0100.04316.60
5.4.60.0070.05316.56
5.4.50.0070.05016.50
5.4.40.0130.06016.51
5.4.30.0070.07016.42
5.4.20.0070.05016.34
5.4.10.0070.05316.40
5.4.00.0070.04715.85
5.3.290.0080.05012.80
5.3.280.0070.05014.73
5.3.270.0100.06014.73
5.3.260.0000.06314.71
5.3.250.0030.05714.63
5.3.240.0070.05014.64
5.3.230.0230.06014.80
5.3.220.0130.06014.52
5.3.210.0100.07014.69
5.3.200.0130.04714.77
5.3.190.0070.07314.79
5.3.180.0070.05014.74
5.3.170.0030.05314.60
5.3.160.0130.04714.58
5.3.150.0000.05714.69
5.3.140.0030.05314.61
5.3.130.0000.05714.68
5.3.120.0100.07314.75
5.3.110.0070.05314.61
5.3.100.0130.05014.23
5.3.90.0000.07314.23
5.3.80.0030.07014.04
5.3.70.0030.05314.13
5.3.60.0030.05014.13
5.3.50.0070.04714.09
5.3.40.0100.05014.06
5.3.30.0070.06713.93
5.3.20.0100.05313.59
5.3.10.0030.05313.78
5.3.00.0170.04713.69
5.2.170.0070.06011.18
5.2.160.0070.04311.25
5.2.150.0030.05311.41
5.2.140.0230.02311.09
5.2.130.0030.06311.37
5.2.120.0100.03711.21
5.2.110.0100.05011.12
5.2.100.0070.05311.13
5.2.90.0000.06011.13
5.2.80.0070.04011.04
5.2.70.0100.05711.36
5.2.60.0100.05311.18
5.2.50.0070.04311.29
5.2.40.0100.04711.11
5.2.30.0130.05011.02
5.2.20.0030.04310.84
5.2.10.0070.03711.13
5.2.00.0100.05010.85
5.1.60.0070.03310.09
5.1.50.0170.02310.00
5.1.40.0070.03010.27
5.1.30.0000.04010.55
5.1.20.0070.03310.47
5.1.10.0070.0339.99
5.1.00.0000.0409.88
5.0.50.0000.0338.80
5.0.40.0070.0378.44
5.0.30.0070.0508.20
5.0.20.0070.0238.33
5.0.10.0030.0338.29
5.0.00.0030.0578.17
4.4.90.0000.0336.96
4.4.80.0070.0276.96
4.4.70.0070.0276.96
4.4.60.0030.0236.96
4.4.50.0070.0176.96
4.4.40.0100.0276.96
4.4.30.0000.0306.96
4.4.20.0000.0336.96
4.4.10.0000.0276.96
4.4.00.0070.0306.96
4.3.110.0070.0236.96
4.3.100.0000.0236.96
4.3.90.0030.0236.96
4.3.80.0070.0336.96
4.3.70.0000.0306.96
4.3.60.0000.0336.96
4.3.50.0070.0276.96
4.3.40.0070.0376.96
4.3.30.0000.0236.96
4.3.20.0030.0306.96
4.3.10.0030.0276.96
4.3.00.0100.01314.52

preferences:
42.22 ms | 401 KiB | 5 Q