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 = str_split(substr($input, $nonBasicCharsStart + 1), 1); } else { $output = []; $nonBasicChars = str_split($input, 1); } $n = 128; $i = 0; $bias = 72; while (!empty($nonBasicChars)) { $oldi = $i; $w = 1; $k = 36; while (true) { $digit = ord(array_shift($nonBasicChars)); 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.01118.43
8.3.50.0100.01221.33
8.3.40.0090.01318.87
8.3.30.0120.00319.02
8.3.20.0080.00019.08
8.3.10.0060.00320.48
8.3.00.0000.00819.38
8.2.180.0130.01016.63
8.2.170.0130.00322.96
8.2.160.0130.00322.21
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00819.83
8.2.110.0030.00721.01
8.2.100.0070.00417.91
8.2.90.0040.00419.30
8.2.80.0000.00917.97
8.2.70.0000.00817.63
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0000.00818.34
8.2.30.0000.00818.18
8.2.20.0000.00717.95
8.2.10.0040.00417.88
8.2.00.0040.00417.93
8.1.280.0100.00725.92
8.1.270.0080.00023.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0090.00020.82
8.1.230.0150.00020.98
8.1.220.0030.00518.77
8.1.210.0030.00518.92
8.1.200.0000.01017.35
8.1.190.0040.00417.54
8.1.180.0000.00818.10
8.1.170.0000.00818.84
8.1.160.0030.00618.87
8.1.150.0000.00818.68
8.1.140.0040.00417.44
8.1.130.0030.00317.88
8.1.120.0030.00517.54
8.1.110.0040.00417.56
8.1.100.0080.00017.50
8.1.90.0040.00417.50
8.1.80.0070.00017.51
8.1.70.0030.00317.52
8.1.60.0040.00417.52
8.1.50.0030.00517.52
8.1.40.0000.01017.55
8.1.30.0050.00317.72
8.1.20.0040.00417.59
8.1.10.0000.00817.54
8.1.00.0040.00417.41
8.0.300.0050.00320.05
8.0.290.0000.00916.88
8.0.280.0050.00318.38
8.0.270.0000.00717.34
8.0.260.0000.00616.80
8.0.250.0080.00017.14
8.0.240.0000.00816.90
8.0.230.0030.00517.07
8.0.220.0000.00716.90
8.0.210.0040.00416.88
8.0.200.0000.00617.08
8.0.190.0040.00417.04
8.0.180.0030.00517.04
8.0.170.0000.00916.99
8.0.160.0040.00417.05
8.0.150.0040.00416.99
8.0.140.0100.00316.88
8.0.130.0060.00013.48
8.0.120.0030.00516.95
8.0.110.0040.00416.89
8.0.100.0040.00417.05
8.0.90.0000.00717.04
8.0.80.0130.00316.94
8.0.70.0000.00816.98
8.0.60.0080.00016.98
8.0.50.0040.00416.81
8.0.30.0130.00817.12
8.0.20.0090.01217.40
8.0.10.0080.00016.96
8.0.00.0130.00616.79
7.4.330.0000.00513.43
7.4.320.0000.00616.57
7.4.300.0030.00316.65
7.4.290.0020.00516.64
7.4.280.0000.00716.45
7.4.270.0000.00716.48
7.4.260.0000.00613.32
7.4.250.0030.00516.59
7.4.240.0040.00416.54
7.4.230.0030.00316.65
7.4.220.0030.02316.71
7.4.210.0090.00616.64
7.4.200.0070.00016.75
7.4.190.0000.00716.68
7.4.160.0030.01316.64
7.4.150.0120.00617.40
7.4.140.0060.01217.24
7.4.130.0100.01016.52
7.4.120.0130.00516.62
7.4.110.0120.00616.55
7.4.100.0240.00016.60
7.4.90.0150.00416.64
7.4.80.0100.00719.03
7.4.70.0090.00916.34
7.4.60.0100.00716.56
7.4.50.0040.00416.54
7.4.40.0070.01122.27
7.4.30.0180.00416.50
7.4.00.0070.00314.81
7.3.330.0070.00013.55
7.3.320.0000.00513.23
7.3.310.0000.00716.53
7.3.300.0030.00316.48
7.3.290.0040.01016.49
7.3.280.0080.00816.49
7.3.270.0070.01117.40
7.3.260.0110.00818.24
7.3.250.0080.01016.54
7.3.240.0100.00716.55
7.3.230.0060.00916.66
7.3.210.0030.01316.40
7.3.200.0060.01519.39
7.3.190.0090.01216.74
7.3.180.0090.00916.45
7.3.170.0090.00716.44
7.3.160.0000.01516.62
7.3.120.0090.00614.92
7.2.330.0150.00316.54
7.2.320.0060.01316.72
7.2.310.0130.01216.54
7.2.300.0110.00716.51
7.2.290.0040.01216.64
7.1.200.0090.00315.92
7.1.70.0000.00916.93
7.1.60.0120.01219.40
7.1.50.0030.01016.69
7.1.00.0030.07722.40
7.0.200.0050.00216.69
7.0.140.0000.07721.98
7.0.60.0070.08019.84
7.0.50.0030.08718.03
7.0.40.0100.04717.86
7.0.30.0070.09017.86
7.0.20.0000.06017.80
7.0.10.0030.08017.74
7.0.00.0030.08317.70
5.6.280.0000.07721.04
5.6.210.0170.07720.49
5.6.200.0100.06718.22
5.6.190.0100.08018.15
5.6.180.0070.08018.24
5.6.170.0070.06718.16
5.6.160.0070.05018.19
5.6.150.0070.04718.19
5.6.140.0070.07318.15
5.6.130.0030.09318.29
5.6.120.0170.07318.18
5.6.110.0030.08018.15
5.6.100.0030.09018.20
5.6.90.0070.08318.16
5.6.80.0000.08317.60
5.6.70.0070.08017.63
5.6.60.0070.06317.59
5.6.50.0100.07317.64
5.6.40.0070.05717.51
5.6.30.0170.06717.53
5.6.20.0100.07017.65
5.6.10.0100.07017.49
5.6.00.0130.06717.48
5.5.350.0130.07320.39
5.5.340.0030.05317.99
5.5.330.0130.05318.02
5.5.320.0030.06317.97
5.5.310.0030.05018.04
5.5.300.0030.08317.98
5.5.290.0070.05718.07
5.5.280.0070.08017.98
5.5.270.0000.05317.97
5.5.260.0100.08017.93
5.5.250.0070.08317.79
5.5.240.0030.07017.39
5.5.230.0070.07317.42
5.5.220.0030.04317.41
5.5.210.0030.05017.37
5.5.200.0130.07317.33
5.5.190.0070.07717.32
5.5.180.0130.07717.33
5.5.160.0130.07017.34
5.5.150.0130.07317.43
5.5.140.0170.05017.41
5.5.130.0000.06017.30
5.5.120.0070.06717.32
5.5.110.0030.07717.33
5.5.100.0070.06017.27
5.5.90.0000.06017.19
5.5.80.0030.05317.21
5.5.70.0070.05017.18
5.5.60.0030.07717.21
5.5.50.0030.07717.21
5.5.40.0030.03717.20
5.5.30.0130.06717.26
5.5.20.0100.07717.29
5.5.10.0100.07017.23
5.5.00.0030.07317.21
5.4.450.0030.08719.36
5.4.440.0100.05019.46
5.4.430.0100.03319.42
5.4.420.0070.08319.30
5.4.410.0000.07319.47
5.4.400.0030.07719.27
5.4.390.0100.05719.07
5.4.380.0030.07019.01
5.4.370.0130.07319.02
5.4.360.0100.04019.05
5.4.350.0170.05019.31
5.4.340.0100.07018.89
5.4.320.0130.06719.05
5.4.310.0030.07319.14
5.4.300.0070.07719.05
5.4.290.0070.06319.05
5.4.280.0200.03719.03
5.4.270.0070.07319.04
5.4.260.0170.07019.01
5.4.250.0030.06018.95
5.4.240.0100.07018.98
5.4.230.0100.06718.95
5.4.220.0070.07019.05
5.4.210.0030.08319.08
5.4.200.0070.05319.11
5.4.190.0070.04319.11
5.4.180.0030.06719.26
5.4.170.0030.04719.04
5.4.160.0100.06719.25
5.4.150.0130.07019.11
5.4.140.0000.05016.49
5.4.130.0100.07016.44
5.4.120.0030.04016.46
5.4.110.0030.03716.31
5.4.100.0030.03716.26
5.4.90.0030.03716.40
5.4.80.0030.03316.41
5.4.70.0000.03716.38
5.4.60.0030.03316.41
5.4.50.0000.03716.53
5.4.40.0000.03716.28
5.4.30.0000.03716.36
5.4.20.0000.03716.39
5.4.10.0000.03716.26
5.4.00.0000.04015.89
5.3.290.0070.08014.75
5.3.280.0030.07714.62
5.3.270.0070.04714.68
5.3.260.0130.07314.59
5.3.250.0070.07314.69
5.3.240.0100.07714.63
5.3.230.0130.05314.59
5.3.220.0070.07314.59
5.3.210.0070.03714.64
5.3.200.0030.03714.63
5.3.190.0030.04314.80
5.3.180.0030.03714.59
5.3.170.0030.03714.57
5.3.160.0030.03714.63
5.3.150.0000.03714.63
5.3.140.0030.03314.62
5.3.130.0030.03714.41
5.3.120.0000.04014.60
5.3.110.0030.03714.59
5.3.100.0070.04014.05
5.3.90.0000.04014.08
5.3.80.0000.03714.02
5.3.70.0030.03314.13
5.3.60.0070.03714.05
5.3.50.0030.03314.00
5.3.40.0030.03314.02
5.3.30.0030.03313.82
5.3.20.0130.02313.64
5.3.10.0130.03313.68
5.3.00.0030.03713.50
5.2.170.0030.02711.22
5.2.160.0030.02711.38
5.2.150.0000.03311.20
5.2.140.0000.03011.24
5.2.130.0030.02711.19
5.2.120.0000.03711.12
5.2.110.0000.03011.13
5.2.100.0000.03011.02
5.2.90.0000.03011.16
5.2.80.0030.02711.10
5.2.70.0030.03011.12
5.2.60.0000.03011.11
5.2.50.0000.03010.95
5.2.40.0030.02311.02
5.2.30.0030.02710.88
5.2.20.0030.02710.93
5.2.10.0030.02710.92
5.2.00.0070.02310.73
5.1.60.0000.03010.01
5.1.50.0000.0239.96
5.1.40.0030.0209.92
5.1.30.0000.02710.32
5.1.20.0000.02710.43
5.1.10.0030.02310.13
5.1.00.0030.04710.16
5.0.50.0030.0378.65
5.0.40.0030.0278.43
5.0.30.0070.0638.22
5.0.20.0000.0378.19
5.0.10.0070.0378.03
5.0.00.0070.0638.23
4.4.90.0030.0137.72
4.4.80.0000.0137.72
4.4.70.0000.0177.72
4.4.60.0000.0177.72
4.4.50.0000.0137.72
4.4.40.0000.0237.72
4.4.30.0030.0137.72
4.4.20.0030.0137.72
4.4.10.0000.0337.72
4.4.00.0030.0307.72
4.3.110.0070.0277.72
4.3.100.0030.0337.72
4.3.90.0030.0377.72
4.3.80.0000.0577.72
4.3.70.0030.0277.72
4.3.60.0000.0277.72
4.3.50.0000.0337.72
4.3.40.0030.0537.72
4.3.30.0000.0277.72
4.3.20.0070.0337.72
4.3.10.0070.0307.72
4.3.00.0000.0377.72

preferences:
34.8 ms | 401 KiB | 5 Q