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); } // 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--') { return $input; } $input = substr($input, 4); if (false !== $nonBasicCharsStart = strrpos($input, '-')) { $output = str_split(substr($input, 0, $nonBasicCharsStart), 1); $nonBasicChars = substr($input, $nonBasicCharsStart + 1); } else { $output = []; $nonBasicChars = $input; } $n = 128; $i = 0; $bias = 72; for ($j = 0, $l = strlen($nonBasicChars); $j < $l;) { $oldi = $i; $w = 1; $k = 36; while (true) { if (!isset($nonBasicChars[$j++])) { return false; } $digit = ord($nonBasicChars[$j++]); if ($digit >= 0x61 && $digit <= 0x7A) { $digit -= 97; } else if ($digit >= 0x30 && $digit <= 0x39) { $digit -= 22; } else { return false; } $i += $digit * $w; if ($k <= $bias) { $t = 1; } else if ($k >= $bias + 26) { $t = 26; } else { $t = $k - $bias; } if ($digit < $t) { break; } $w *= (int) (36 - $t); $k += 36; } $c = count($output) + 1; $bias = IDN::punyAdapt($i - $oldi, $c, $oldi === 0); $n += (int)($i / $c); $i %= $c; 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.0070.00716.88
8.3.50.0120.00917.49
8.3.40.0090.00618.96
8.3.30.0120.00318.75
8.3.20.0080.00018.87
8.3.10.0040.00420.39
8.3.00.0070.00719.51
8.2.180.0150.00616.75
8.2.170.0070.01122.96
8.2.160.0060.00921.17
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0030.00626.16
8.2.120.0040.00420.89
8.2.110.0070.00419.39
8.2.100.0090.00318.34
8.2.90.0080.00017.88
8.2.80.0040.00418.99
8.2.70.0080.00017.93
8.2.60.0080.00018.28
8.2.50.0090.00018.10
8.2.40.0110.00019.43
8.2.30.0070.00019.38
8.2.20.0040.00419.44
8.2.10.0040.00417.79
8.2.00.0040.00417.92
8.1.280.0090.00625.92
8.1.270.0050.00324.66
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0030.00620.46
8.1.230.0030.00718.86
8.1.220.0040.00417.78
8.1.210.0040.00418.77
8.1.200.0030.00717.36
8.1.190.0030.00617.35
8.1.180.0080.00018.10
8.1.170.0000.00918.66
8.1.160.0030.00518.81
8.1.150.0000.00718.98
8.1.140.0040.00417.50
8.1.130.0030.00317.82
8.1.120.0000.00717.43
8.1.110.0000.00717.37
8.1.100.0070.00017.46
8.1.90.0000.00817.54
8.1.80.0040.00417.54
8.1.70.0000.00717.53
8.1.60.0060.00317.61
8.1.50.0040.00417.51
8.1.40.0000.00817.50
8.1.30.0000.00817.64
8.1.20.0000.00817.72
8.1.10.0000.00917.65
8.1.00.0060.00617.40
8.0.300.0080.00018.77
8.0.290.0040.00416.88
8.0.280.0070.00018.56
8.0.270.0000.00717.31
8.0.260.0040.00416.81
8.0.250.0060.00617.11
8.0.240.0030.00717.05
8.0.230.0000.00717.06
8.0.220.0000.00717.00
8.0.210.0000.00816.90
8.0.200.0060.00017.13
8.0.190.0040.00417.05
8.0.180.0000.00817.04
8.0.170.0030.00616.92
8.0.160.0060.00316.96
8.0.150.0050.00316.88
8.0.140.0040.00416.87
8.0.130.0030.00313.48
8.0.120.0000.00816.96
8.0.110.0040.00416.98
8.0.100.0000.00716.87
8.0.90.0030.00516.82
8.0.80.0110.00616.98
8.0.70.0000.00817.01
8.0.60.0070.00016.89
8.0.50.0070.00017.00
8.0.30.0120.00817.24
8.0.20.0140.01117.10
8.0.10.0000.00816.94
8.0.00.0080.01416.91
7.4.330.0050.00013.04
7.4.320.0070.00016.66
7.4.300.0070.00016.59
7.4.290.0030.00316.53
7.4.280.0040.00416.70
7.4.270.0000.00716.55
7.4.260.0030.00313.32
7.4.250.0030.00616.53
7.4.240.0050.00316.58
7.4.230.0030.00316.48
7.4.220.0100.01016.63
7.4.210.0060.00916.57
7.4.200.0030.00416.66
7.4.190.0030.00316.50
7.4.160.0060.01116.39
7.4.150.0160.00316.36
7.4.140.0120.00616.58
7.4.130.0080.01016.39
7.4.120.0110.00816.55
7.4.110.0040.01416.55
7.4.100.0060.01216.71
7.4.90.0080.01116.54
7.4.80.0090.00919.39
7.4.70.0120.00616.35
7.4.60.0130.00316.54
7.4.50.0120.00016.61
7.4.40.0070.01116.55
7.4.30.0140.00316.47
7.4.00.0030.01314.86
7.3.330.0060.00013.34
7.3.320.0030.00313.31
7.3.310.0000.00716.48
7.3.300.0050.00216.49
7.3.290.0060.00916.52
7.3.280.0080.01016.46
7.3.270.0090.01516.52
7.3.260.0120.00916.72
7.3.250.0120.01016.54
7.3.240.0100.00716.57
7.3.230.0140.01016.41
7.3.210.0090.00916.39
7.3.200.0110.01116.60
7.3.190.0060.00916.41
7.3.180.0100.00616.40
7.3.170.0110.00716.53
7.3.160.0120.00616.49
7.3.120.0120.00315.18
7.2.330.0090.01216.61
7.2.320.0120.00916.87
7.2.310.0120.00616.92
7.2.300.0070.01016.80
7.2.290.0140.00316.66
7.2.60.0070.01017.05
7.2.00.0090.00619.33
7.1.200.0060.00615.83
7.1.100.0060.00618.18
7.1.70.0030.00517.21
7.1.60.0170.00719.40
7.1.50.0080.00816.92
7.1.00.0030.07022.32
7.0.200.0040.00716.72
7.0.140.0000.07722.00
7.0.120.0000.07722.19
7.0.60.0000.06019.99
7.0.50.0100.06017.92
7.0.40.0070.04717.69
7.0.30.0030.08017.69
7.0.20.0100.08317.75
7.0.10.0030.08717.75
7.0.00.0070.04017.75
5.6.280.0100.06721.12
5.6.210.0130.07020.62
5.6.200.0030.05018.14
5.6.190.0130.07318.19
5.6.180.0100.07718.14
5.6.170.0070.04718.21
5.6.160.0030.08318.19
5.6.150.0170.03718.25
5.6.140.0000.04718.24
5.6.130.0100.07718.18
5.6.120.0070.08718.21
5.6.110.0130.05718.21
5.6.100.0070.05718.18
5.6.90.0070.04018.16
5.6.80.0100.03317.67
5.6.70.0070.03317.63
5.6.60.0030.03717.65
5.6.50.0030.03717.54
5.6.40.0030.03717.49
5.6.30.0000.04017.61
5.6.20.0000.04017.60
5.6.10.0030.05717.65
5.6.00.0030.03717.53
5.5.350.0300.06720.47
5.5.340.0130.04317.94
5.5.330.0130.05317.99
5.5.320.0030.08017.99
5.5.310.0130.07017.94
5.5.300.0070.08018.04
5.5.290.0100.04318.09
5.5.280.0130.06018.00
5.5.270.0030.06317.98
5.5.260.0030.07318.04
5.5.250.0030.04017.88
5.5.240.0000.04017.35
5.5.230.0030.03717.36
5.5.220.0070.03717.34
5.5.210.0030.03717.46
5.5.200.0000.04017.44
5.5.190.0030.03717.29
5.5.180.0000.04017.31
5.5.160.0030.03717.33
5.5.150.0030.03717.43
5.5.140.0000.04017.43
5.5.130.0170.04017.37
5.5.120.0070.04317.42
5.5.110.0070.03317.28
5.5.100.0030.03717.24
5.5.90.0030.03717.21
5.5.80.0070.04017.18
5.5.70.0070.04017.23
5.5.60.0030.03717.29
5.5.50.0070.03017.33
5.5.40.0030.07017.29
5.5.30.0100.07317.17
5.5.20.0070.04717.32
5.5.10.0130.06017.22
5.5.00.0100.04717.23
5.4.450.0130.07319.32
5.4.440.0070.05719.31
5.4.430.0070.08019.36
5.4.420.0070.05019.44
5.4.410.0030.03719.27
5.4.400.0030.04019.27
5.4.390.0000.04019.02
5.4.380.0070.03319.02
5.4.370.0130.03018.98
5.4.360.0000.04019.01
5.4.350.0000.04019.04
5.4.340.0030.03719.12
5.4.320.0030.04019.16
5.4.310.0030.03719.01
5.4.300.0030.03719.11
5.4.290.0030.03719.05
5.4.280.0030.03719.01
5.4.270.0000.04319.02
5.4.260.0030.03719.00
5.4.250.0000.04019.05
5.4.240.0000.04019.02
5.4.230.0000.04018.94
5.4.220.0030.03719.00
5.4.210.0030.03718.95
5.4.200.0030.06319.04
5.4.190.0130.06719.00
5.4.180.0070.06019.11
5.4.170.0070.07319.05
5.4.160.0000.04719.01
5.4.150.0130.07319.25
5.4.140.0070.07316.36
5.4.130.0100.06316.35
5.4.120.0000.06316.40
5.4.110.0100.07316.32
5.4.100.0070.04716.37
5.4.90.0030.04316.41
5.4.80.0070.04716.59
5.4.70.0070.03716.63
5.4.60.0100.06316.34
5.4.50.0100.07016.39
5.4.40.0070.07316.32
5.4.30.0070.04316.43
5.4.20.0070.07016.38
5.4.10.0000.06716.29
5.4.00.0070.07316.02
5.3.290.0000.04014.73
5.3.280.0030.03714.65
5.3.270.0100.06714.62
5.3.260.0000.04714.66
5.3.250.0100.05014.63
5.3.240.0130.07014.67
5.3.230.0070.06714.65
5.3.220.0070.07314.40
5.3.210.0170.06014.62
5.3.200.0100.07014.62
5.3.190.0000.04014.66
5.3.180.0070.06014.63
5.3.170.0100.07014.68
5.3.160.0130.05014.64
5.3.150.0070.08014.43
5.3.140.0100.06314.61
5.3.130.0070.05714.57
5.3.120.0130.03714.66
5.3.110.0030.06314.62
5.3.100.0070.07014.08
5.3.90.0070.06714.06
5.3.80.0170.06314.02
5.3.70.0170.06313.88
5.3.60.0070.06714.06
5.3.50.0070.07714.18
5.3.40.0000.04714.03
5.3.30.0070.07313.82
5.3.20.0000.07313.60
5.3.10.0170.06013.66
5.3.00.0030.04313.70
5.2.170.0030.06711.16
5.2.160.0100.05711.06
5.2.150.0030.03011.16
5.2.140.0030.04011.26
5.2.130.0130.05311.11
5.2.120.0070.06310.97
5.2.110.0100.02711.16
5.2.100.0130.05311.33
5.2.90.0030.03711.35
5.2.80.0100.05711.13
5.2.70.0100.05711.21
5.2.60.0070.06311.11
5.2.50.0070.04010.93
5.2.40.0000.04011.01
5.2.30.0000.03010.96
5.2.20.0130.03010.93
5.2.10.0030.04710.87
5.2.00.0100.04310.95
5.1.60.0030.04310.12
5.1.50.0070.03710.09
5.1.40.0000.04010.00
5.1.30.0100.04310.20
5.1.20.0030.05310.48
5.1.10.0070.05710.13
5.1.00.0030.03710.08
5.0.50.0070.0438.79
5.0.40.0000.0238.48
5.0.30.0100.0308.23
5.0.20.0030.0478.27
5.0.10.0030.0478.40
5.0.00.0100.0508.18
4.4.90.0070.0177.89
4.4.80.0030.0137.89
4.4.70.0070.0207.89
4.4.60.0000.0337.89
4.4.50.0100.0207.89
4.4.40.0030.0377.89
4.4.30.0030.0237.89
4.4.20.0000.0337.89
4.4.10.0000.0377.89
4.4.00.0000.0437.89
4.3.110.0000.0207.89
4.3.100.0000.0177.89
4.3.90.0100.0307.89
4.3.80.0070.0337.89
4.3.70.0030.0377.89
4.3.60.0000.0237.89
4.3.50.0000.0377.89
4.3.40.0030.0507.89
4.3.30.0000.0207.89
4.3.20.0000.0307.89
4.3.10.0000.0177.89
4.3.00.0030.0177.89

preferences:
45.25 ms | 401 KiB | 5 Q