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, '-')) { $nonBasicChars = str_split(substr($input, $nonBasicCharsStart + 1), 1); $output = str_split(substr($input, 0, $nonBasicCharsStart), 1); } else { $nonBasicChars = str_split($input, 1); $output = []; } $n = 128; $i = 0; $bias = 72; // init punycode vars while (!empty($input)) { $oldi = $i; $w = 1; for ($k = 36;;) { $digit = ord(array_shift($input)); 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; } $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.0120.00616.88
8.3.50.0100.00621.21
8.3.40.0110.00818.79
8.3.30.0030.01718.98
8.3.20.0000.00720.34
8.3.10.0060.00322.08
8.3.00.0030.00522.40
8.2.180.0120.00617.00
8.2.170.0070.00722.96
8.2.160.0110.00419.34
8.2.150.0080.00024.18
8.2.140.0090.01224.66
8.2.130.0040.01126.16
8.2.120.0070.00317.68
8.2.110.0040.00420.53
8.2.100.0060.00617.72
8.2.90.0040.00417.61
8.2.80.0070.00318.82
8.2.70.0090.00017.50
8.2.60.0040.00417.93
8.2.50.0060.00318.07
8.2.40.0030.00518.29
8.2.30.0050.00318.14
8.2.20.0040.00417.72
8.2.10.0040.00417.86
8.2.00.0040.00417.75
8.1.280.0150.00025.92
8.1.270.0040.00418.54
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0030.00618.92
8.1.230.0090.00317.82
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00717.47
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0080.00418.48
8.1.160.0050.00518.85
8.1.150.0020.00520.13
8.1.140.0040.00417.41
8.1.130.0060.00617.83
8.1.120.0060.00317.49
8.1.110.0080.00017.47
8.1.100.0070.00017.51
8.1.90.0040.00417.49
8.1.80.0050.00317.50
8.1.70.0030.00317.54
8.1.60.0080.00017.61
8.1.50.0080.00017.58
8.1.40.0050.00317.46
8.1.30.0000.00817.70
8.1.20.0050.00317.68
8.1.10.0050.00317.60
8.1.00.0030.00517.57
8.0.300.0060.00318.77
8.0.290.0090.00016.88
8.0.280.0030.00318.49
8.0.270.0070.00017.35
8.0.260.0030.00316.85
8.0.250.0030.00317.06
8.0.240.0060.00317.05
8.0.230.0030.00317.13
8.0.220.0040.00416.93
8.0.210.0080.00016.84
8.0.200.0060.00017.03
8.0.190.0000.00916.94
8.0.180.0020.00517.02
8.0.170.0000.00816.96
8.0.160.0050.00316.91
8.0.150.0020.00516.94
8.0.140.0000.00816.99
8.0.130.0030.00313.38
8.0.120.0060.00316.83
8.0.110.0040.00416.94
8.0.100.0040.00417.10
8.0.90.0070.00016.80
8.0.80.0060.01017.03
8.0.70.0000.00717.05
8.0.60.0030.00617.00
8.0.50.0000.00817.00
8.0.30.0100.00917.22
8.0.20.0150.00817.40
8.0.10.0070.00017.15
8.0.00.0090.00816.83
7.4.330.0030.00315.00
7.4.320.0000.00616.48
7.4.300.0000.00616.53
7.4.290.0040.00416.66
7.4.280.0000.00716.63
7.4.270.0040.00416.46
7.4.260.0040.00416.61
7.4.250.0040.00416.54
7.4.240.0020.00516.52
7.4.230.0000.00716.59
7.4.220.0160.00516.68
7.4.210.0090.00516.59
7.4.200.0030.00516.73
7.4.190.0050.00216.62
7.4.160.0090.00616.54
7.4.150.0110.00617.40
7.4.140.0100.01017.86
7.4.130.0100.00816.54
7.4.120.0080.01116.61
7.4.110.0090.00916.63
7.4.100.0120.00616.63
7.4.90.0150.00316.50
7.4.80.0090.00919.39
7.4.70.0070.01016.55
7.4.60.0040.01816.73
7.4.50.0000.00416.66
7.4.40.0060.00822.77
7.4.30.0140.00316.64
7.4.00.0070.00715.25
7.3.330.0050.00013.46
7.3.320.0000.00813.55
7.3.310.0030.00316.33
7.3.300.0070.00016.35
7.3.290.0090.00616.44
7.3.280.0090.00816.43
7.3.270.0110.00717.40
7.3.260.0100.00916.55
7.3.250.0100.00816.53
7.3.240.0130.00316.41
7.3.230.0040.01416.57
7.3.210.0060.01016.62
7.3.200.0150.00719.39
7.3.190.0130.01016.62
7.3.180.0060.01616.61
7.3.170.0090.01416.47
7.3.160.0120.00816.39
7.3.120.0090.00614.85
7.2.330.0070.01016.79
7.2.320.0060.01216.71
7.2.310.0060.01616.76
7.2.300.0120.00616.80
7.2.290.0090.01316.77
7.2.60.0070.01016.84
7.2.00.0040.00919.45
7.1.200.0060.00615.51
7.1.100.0040.01118.04
7.1.70.0050.00317.00
7.1.60.0100.00319.82
7.1.50.0150.00917.14
7.1.00.0000.03722.36
7.0.200.0000.00816.73
7.0.140.0030.07022.22
7.0.60.0070.08020.12
7.0.50.0030.04717.77
7.0.40.0100.08720.40
7.0.30.0400.05020.09
7.0.20.0270.07720.19
7.0.10.0270.05720.10
7.0.00.0100.07320.07
5.6.210.0100.07320.55
5.6.200.0100.07718.19
5.6.190.0200.07320.67
5.6.180.3170.04020.42
5.6.170.0330.04320.54
5.6.160.0100.08020.52
5.6.150.0100.03318.25
5.6.140.0070.04318.18
5.6.130.0030.07318.18
5.6.120.0130.08321.12
5.6.110.0070.05021.16
5.6.100.0130.08021.11
5.6.90.0100.05021.00
5.6.80.0100.04020.46
5.6.70.0230.08020.45
5.5.350.0170.07020.35
5.5.340.0170.06717.99
5.5.330.0200.07320.21
5.5.320.0300.07020.24
5.5.310.0330.08020.32
5.5.300.0100.06317.97
5.5.290.0170.07317.95
5.5.280.0030.09020.82
5.5.270.0100.06720.79
5.5.260.0270.02320.74
5.5.250.0100.06720.64
5.5.240.0070.06020.18
5.4.450.0730.05319.17
5.4.440.0630.07719.39
5.4.430.0930.05719.30
5.4.420.0630.06019.46
5.4.410.0730.06319.21
5.4.400.0270.05718.63
5.4.390.0570.04718.60
5.4.380.0170.06318.79
5.4.370.0130.05318.63
5.4.360.0200.04718.59
5.4.350.0080.05112.04
5.4.340.0120.04212.03
5.4.320.0040.04512.52
5.4.310.0060.04512.52
5.4.300.0100.05012.52
5.4.290.0060.04712.52
5.4.280.0060.04012.42
5.4.270.0090.03412.42
5.4.260.0070.03712.41
5.4.250.0100.05018.76
5.4.240.0100.05018.95
5.4.230.0100.07018.76
5.4.220.0100.05018.62
5.4.210.0130.06018.89
5.4.200.0200.04018.92
5.4.190.0070.05318.75
5.4.180.0100.04718.95
5.4.170.0070.05318.98
5.4.160.0100.05718.95
5.4.150.0100.05718.85
5.4.140.0130.05316.59
5.4.130.0170.05016.34
5.4.120.0100.04716.43
5.4.110.0000.06016.50
5.4.100.0030.05016.35
5.4.90.0030.05316.52
5.4.80.0130.04316.30
5.4.70.0130.04016.56
5.4.60.0000.05316.46
5.4.50.0170.05716.29
5.4.40.0030.05016.40
5.4.30.0030.05316.49
5.4.20.0030.05316.46
5.4.10.0070.07316.36
5.4.00.0200.05315.83
5.3.290.0090.04412.80
5.3.280.0000.06014.83
5.3.270.0070.05714.61
5.3.260.0030.05314.71
5.3.250.0100.05014.71
5.3.240.0230.06014.61
5.3.230.0100.05014.68
5.3.220.0070.05014.81
5.3.210.0070.05314.61
5.3.200.0130.04314.72
5.3.190.0170.06714.68
5.3.180.0200.04314.66
5.3.170.0070.05014.68
5.3.160.0130.04314.41
5.3.150.0130.04314.72
5.3.140.0170.04014.60
5.3.130.0130.06014.75
5.3.120.0170.06714.56
5.3.110.0130.06014.66
5.3.100.0100.05314.04
5.3.90.0030.06314.02
5.3.80.0030.05714.12
5.3.70.0000.05314.04
5.3.60.0000.05313.85
5.3.50.0130.05713.88
5.3.40.0100.04314.05
5.3.30.0130.05713.90
5.3.20.0070.05013.80
5.3.10.0100.04313.58
5.3.00.0000.05313.68
5.2.170.0130.03311.38
5.2.160.0030.04011.15
5.2.150.0000.05711.25
5.2.140.0070.04011.14
5.2.130.0070.03711.04
5.2.120.0100.03311.02
5.2.110.0070.04011.18
5.2.100.0170.03311.07
5.2.90.0000.04311.29
5.2.80.0000.05011.12
5.2.70.0100.03711.13
5.2.60.0100.03711.03
5.2.50.0000.04711.21
5.2.40.0000.04311.10
5.2.30.0030.04311.09
5.2.20.0030.04011.20
5.2.10.0070.03710.97
5.2.00.0100.03310.57
5.1.60.0070.03010.07
5.1.50.0070.03310.03
5.1.40.0130.03010.01
5.1.30.0070.03310.44
5.1.20.0000.04010.55
5.1.10.0070.03710.11
5.1.00.0100.04010.08
5.0.50.0030.0278.82
5.0.40.0030.0378.44
5.0.30.0000.0438.21
5.0.20.0030.0278.31
5.0.10.0070.0278.24
5.0.00.0030.0578.15
4.4.90.0000.0237.00
4.4.80.0000.0237.00
4.4.70.0100.0137.00
4.4.60.0030.0207.00
4.4.50.0070.0177.00
4.4.40.0070.0307.00
4.4.30.0030.0207.00
4.4.20.0030.0207.00
4.4.10.0070.0176.96
4.4.00.0070.0306.96
4.3.110.0030.0206.96
4.3.100.0030.0206.96
4.3.90.0030.0306.96
4.3.80.0000.0406.96
4.3.70.0000.0236.96
4.3.60.0070.0176.96
4.3.50.0000.0236.96
4.3.40.0030.0376.96
4.3.30.0070.0176.96
4.3.20.0000.0236.96
4.3.10.0000.0236.96
4.3.00.0100.0277.61

preferences:
57.39 ms | 400 KiB | 5 Q