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, '-')) { $input = str_split(substr($input, $nonBasicCharsStart + 1), 1); $output = str_split(substr($input, 0, $nonBasicCharsStart), 1); } else { $input = 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.0160.00616.88
8.3.50.0050.01221.27
8.3.40.0090.00618.79
8.3.30.0090.00619.20
8.3.20.0070.00020.20
8.3.10.0040.00421.90
8.3.00.0000.00822.45
8.2.180.0040.01416.63
8.2.170.0100.00722.96
8.2.160.0110.00419.06
8.2.150.0080.00024.18
8.2.140.0040.00724.66
8.2.130.0070.00726.16
8.2.120.0120.00017.68
8.2.110.0030.00720.59
8.2.100.0000.01217.91
8.2.90.0030.00519.22
8.2.80.0050.00517.97
8.2.70.0050.00517.62
8.2.60.0030.00617.68
8.2.50.0080.00018.10
8.2.40.0050.00318.22
8.2.30.0000.00718.08
8.2.20.0000.00817.61
8.2.10.0000.00817.73
8.2.00.0080.00017.65
8.1.280.0060.01225.92
8.1.270.0090.00018.50
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0070.01020.96
8.1.230.0050.01017.42
8.1.220.0050.00317.74
8.1.210.0080.00018.77
8.1.200.0050.00517.23
8.1.190.0040.00417.35
8.1.180.0050.00318.10
8.1.170.0040.00418.53
8.1.160.0070.00022.10
8.1.150.0050.00218.54
8.1.140.0000.00717.36
8.1.130.0030.00517.86
8.1.120.0040.00417.52
8.1.110.0000.00717.43
8.1.100.0050.00217.32
8.1.90.0040.00417.41
8.1.80.0040.00417.33
8.1.70.0040.00417.33
8.1.60.0000.00917.63
8.1.50.0040.00417.45
8.1.40.0050.00317.63
8.1.30.0050.00217.57
8.1.20.0000.00817.61
8.1.10.0050.00317.58
8.1.00.0050.00217.57
8.0.300.0000.00718.77
8.0.290.0030.00616.63
8.0.280.0030.00318.34
8.0.270.0040.00417.23
8.0.260.0030.00316.78
8.0.250.0040.00416.97
8.0.240.0040.00417.04
8.0.230.0080.00016.94
8.0.220.0040.00416.81
8.0.210.0000.00716.83
8.0.200.0030.00316.88
8.0.190.0080.00017.04
8.0.180.0000.00916.93
8.0.170.0050.00217.03
8.0.160.0060.00316.97
8.0.150.0040.00416.80
8.0.140.0040.00416.91
8.0.130.0000.00613.41
8.0.120.0000.00816.86
8.0.110.0070.00016.91
8.0.100.0030.00516.89
8.0.90.0000.00816.80
8.0.80.0090.00616.89
8.0.70.0050.00216.97
8.0.60.0030.00516.90
8.0.50.0000.00817.01
8.0.30.0080.01017.09
8.0.20.0140.00317.42
8.0.10.0000.00717.02
8.0.00.0090.00816.99
7.4.330.0000.00515.00
7.4.320.0070.00016.41
7.4.300.0030.00316.67
7.4.290.0060.00316.41
7.4.280.0030.00316.45
7.4.270.0030.00316.48
7.4.260.0040.00416.61
7.4.250.0080.00016.43
7.4.240.0060.00116.50
7.4.230.0030.00316.73
7.4.220.0060.01116.59
7.4.210.0040.01116.64
7.4.200.0040.00416.58
7.4.190.0030.00416.80
7.4.160.0090.00616.69
7.4.150.0110.01517.40
7.4.140.0080.01317.86
7.4.130.0120.00916.65
7.4.120.0090.01116.53
7.4.110.0060.01116.55
7.4.100.0100.01316.65
7.4.90.0070.01116.27
7.4.80.0170.00319.39
7.4.70.0180.00016.59
7.4.60.0030.01316.46
7.4.50.0040.00016.38
7.4.40.0000.01622.77
7.4.30.0030.01216.47
7.4.10.0140.00714.96
7.4.00.0040.00915.18
7.3.330.0000.00513.48
7.3.320.0030.00413.34
7.3.310.0000.00816.38
7.3.300.0040.00416.53
7.3.290.0120.00916.45
7.3.280.0040.01416.50
7.3.270.0070.01117.40
7.3.260.0040.01316.52
7.3.250.0090.00816.53
7.3.240.0170.00016.70
7.3.230.0090.01516.61
7.3.210.0100.00616.52
7.3.200.0080.00819.39
7.3.190.0090.00816.61
7.3.180.0080.00816.57
7.3.170.0110.00616.50
7.3.160.0040.01216.54
7.3.130.0090.01215.03
7.3.120.0090.01014.95
7.3.110.0070.01015.04
7.3.100.0030.01315.03
7.3.90.0060.00614.73
7.3.80.0070.00714.95
7.3.70.0030.01314.86
7.3.60.0040.01214.92
7.3.50.0090.00614.55
7.3.40.0090.00015.02
7.3.30.0030.00914.99
7.3.20.0070.00316.40
7.3.10.0060.00916.71
7.3.00.0090.00816.44
7.2.330.0110.00816.60
7.2.320.0160.00416.80
7.2.310.0100.01316.91
7.2.300.0070.01016.70
7.2.290.0030.01316.75
7.2.260.0120.00914.99
7.2.250.0100.01015.22
7.2.240.0000.01415.33
7.2.230.0070.01114.97
7.2.220.0040.01415.11
7.2.210.0040.00815.11
7.2.200.0120.00614.98
7.2.190.0070.01015.10
7.2.180.0100.00315.21
7.2.170.0000.00915.16
7.2.160.0100.00715.21
7.2.150.0030.01217.04
7.2.140.0030.01416.80
7.2.130.0080.00816.56
7.2.120.0070.00816.96
7.2.110.0090.00616.71
7.2.100.0050.00916.80
7.2.90.0100.00716.62
7.2.80.0100.00716.87
7.2.70.0050.01416.81
7.2.60.0040.01116.90
7.2.50.0040.01316.42
7.2.40.0060.00916.79
7.2.30.0050.01416.88
7.2.20.0090.01016.56
7.2.10.0120.00816.86
7.2.00.0040.01516.96
7.1.330.0000.01315.55
7.1.320.0040.01515.83
7.1.310.0120.00015.89
7.1.300.0040.01115.60
7.1.290.0030.00815.48
7.1.280.0000.01015.73
7.1.270.0000.00915.64
7.1.260.0060.01015.75
7.1.250.0090.00515.55
7.1.240.0000.01815.81
7.1.230.0040.01115.98
7.1.220.0030.00915.80
7.1.210.0070.00715.82
7.1.200.0090.00615.79
7.1.190.0030.00915.68
7.1.180.0000.00815.61
7.1.170.0030.00615.55
7.1.160.0100.00315.83
7.1.150.0000.01715.62
7.1.140.0060.00915.94
7.1.130.0080.00415.61
7.1.120.0100.00715.86
7.1.110.0000.01815.86
7.1.100.0060.00917.02
7.1.90.0000.01015.75
7.1.80.0060.00615.82
7.1.70.0070.00616.36
7.1.60.0080.01017.72
7.1.50.0060.01116.35
7.1.40.0080.00315.99
7.1.30.0030.01315.79
7.1.20.0100.01015.69
7.1.10.0040.00715.94
7.1.00.0020.02318.98
7.0.330.0070.00715.34
7.0.320.0030.01015.21
7.0.310.0030.01015.54
7.0.300.0060.00615.38
7.0.290.0080.00015.48
7.0.280.0070.00715.34
7.0.270.0070.00715.44
7.0.260.0080.00815.46
7.0.250.0070.01115.42
7.0.240.0070.01015.52
7.0.230.0040.00415.41
7.0.220.0100.00315.19
7.0.210.0030.01215.21
7.0.200.0010.00816.10
7.0.190.0000.01215.43
7.0.180.0120.00315.29
7.0.170.0030.01315.46
7.0.160.0120.00615.46
7.0.150.0030.00615.41
7.0.140.0100.03718.75
7.0.130.0040.01115.54
7.0.120.0000.01015.54
7.0.110.0150.00015.31
7.0.100.0000.00915.46
7.0.90.0060.00815.54
7.0.80.0040.01115.52
7.0.70.0040.00415.52
7.0.60.0050.03917.79
7.0.50.0130.02316.65
7.0.40.0060.02516.74
7.0.30.0180.03016.86
7.0.20.0220.02716.80
7.0.10.0090.04116.85
7.0.00.0110.02116.85
5.6.400.0090.00614.18
5.6.390.0060.01214.25
5.6.380.0070.00714.63
5.6.370.0110.00614.59
5.6.360.0030.00614.75
5.6.350.0100.00714.51
5.6.340.0000.01814.71
5.6.330.0040.00814.51
5.6.320.0040.01414.54
5.6.310.0090.00614.45
5.6.300.0030.00914.59
5.6.290.0040.00714.33
5.6.280.0050.03817.70
5.6.270.0100.00714.71
5.6.260.0030.00614.44
5.6.250.0030.01014.80
5.6.240.0040.01114.32
5.6.230.0000.01514.30
5.6.220.0100.00714.49
5.6.210.0080.04117.69
5.6.200.0100.04516.27
5.6.190.0050.03117.42
5.6.180.0160.02417.36
5.6.170.0170.04217.50
5.6.160.0030.02517.40
5.6.150.0060.02516.19
5.6.140.0090.03416.34
5.6.130.0070.03616.23
5.6.120.0070.04517.72
5.6.110.0140.03017.67
5.6.100.0080.04317.82
5.6.90.0060.02517.71
5.6.80.0070.03717.35
5.6.70.2120.02317.43
5.6.60.0030.00914.21
5.6.50.0080.00814.42
5.6.40.0040.01114.43
5.6.30.0000.01214.10
5.6.20.0090.00614.40
5.6.10.0000.00914.48
5.6.00.0030.01014.41
5.5.380.0060.00614.30
5.5.370.0060.00614.32
5.5.360.0000.01414.28
5.5.350.0050.04317.14
5.5.340.0080.02016.09
5.5.330.0050.04917.21
5.5.320.0180.03817.26
5.5.310.0250.03717.21
5.5.300.0090.03716.24
5.5.290.0060.04516.08
5.5.280.0100.03717.34
5.5.270.0100.04417.61
5.5.260.0020.04817.33
5.5.250.0120.04517.40
5.5.240.0090.03217.42
5.5.230.0110.00314.34
5.5.220.0060.00914.21
5.5.210.0000.01413.96
5.5.200.0040.01114.12
5.5.190.0060.00914.17
5.5.180.0060.00614.26
5.5.170.0050.00514.26
5.5.160.0040.01114.21
5.5.150.0090.00614.29
5.5.140.0040.01414.05
5.5.130.0030.00914.43
5.5.120.0080.00414.40
5.5.110.0070.00714.44
5.5.100.0000.01114.27
5.5.90.0060.00314.36
5.5.80.0070.00314.34
5.5.70.0080.00514.37
5.5.60.0120.00314.48
5.5.50.0070.00714.57
5.5.40.0040.01114.20
5.5.30.0060.00314.54
5.5.20.0030.01313.83
5.5.10.0030.01214.34
5.5.00.0000.01314.26
5.4.450.0330.03215.19
5.4.440.0410.03315.08
5.4.430.0330.03315.33
5.4.420.0480.03215.20
5.4.410.0290.03415.11
5.4.400.0240.02714.87
5.4.390.0200.02914.92
5.4.380.0210.02614.89
5.4.370.0080.03014.76
5.4.360.0100.02614.92
5.4.350.0090.02311.53
5.4.340.0080.02211.61
5.4.330.0000.01210.79
5.4.320.0090.02011.88
5.4.310.0070.02711.76
5.4.300.0050.02111.94
5.4.290.0040.02311.85
5.4.280.0060.02011.76
5.4.270.0040.01911.70
5.4.260.0040.02511.72
5.4.250.0000.04914.93
5.4.240.0070.02714.94
5.4.230.0130.02714.76
5.4.220.0090.02914.84
5.4.210.0040.03415.04
5.4.200.0110.02514.97
5.4.190.0100.03014.77
5.4.180.0020.03515.03
5.4.170.0050.03914.87
5.4.160.0090.04015.23
5.4.150.0120.04114.90
5.4.140.0130.02813.70
5.4.130.0050.04213.76
5.4.120.0050.03913.66
5.4.110.0100.02713.86
5.4.100.0080.03313.77
5.4.90.0070.02513.55
5.4.80.0070.02613.71
5.4.70.0030.03013.79
5.4.60.0050.03013.54
5.4.50.0110.02813.82
5.4.40.0020.03013.72
5.4.30.0080.02713.68
5.4.20.0140.03013.71
5.4.10.0050.04213.79
5.4.00.0030.02713.56
5.3.290.0050.02311.53
5.3.280.0050.03012.55
5.3.270.0050.03612.58
5.3.260.0070.04212.48
5.3.250.0050.03012.53
5.3.240.0100.03612.36
5.3.230.0180.02812.48
5.3.220.0140.03012.38
5.3.210.0070.03312.40
5.3.200.0050.03112.52
5.3.190.0100.03612.50
5.3.180.0070.02712.53
5.3.170.0060.03212.54
5.3.160.0050.02712.59
5.3.150.0040.03712.58
5.3.140.0060.04012.46
5.3.130.0050.03112.53
5.3.120.0060.02812.54
5.3.110.0080.03712.49
5.3.100.0050.02812.31
5.3.90.0070.02912.30
5.3.80.0090.02412.24
5.3.70.0060.03812.20
5.3.60.0080.02412.14
5.3.50.0050.02812.11
5.3.40.0110.02312.15
5.3.30.0030.02912.04
5.3.20.0050.03212.00
5.3.10.0080.02912.01
5.3.00.0060.03111.95
5.2.170.0170.04711.32
5.2.160.0030.04011.35
5.2.150.0070.04011.13
5.2.140.0030.04711.25
5.2.130.0030.04311.11
5.2.120.0070.04711.30
5.2.110.0100.03711.22
5.2.100.0100.04311.13
5.2.90.0170.04311.20
5.2.80.0100.05311.10
5.2.70.0200.04011.20
5.2.60.0000.04311.14
5.2.50.0000.04311.23
5.2.40.0030.04011.12
5.2.30.0030.04310.95
5.2.20.0070.05011.05
5.2.10.0130.03011.05
5.2.00.0000.04710.83
5.1.60.0000.04310.09
5.1.50.0030.03310.08
5.1.40.0070.03010.07
5.1.30.0070.03010.43
5.1.20.0030.03710.46
5.1.10.0000.05010.18
5.1.00.0030.03710.02
5.0.50.0130.0178.61
5.0.40.0000.0278.50
5.0.30.0030.0438.28
5.0.20.0000.0308.27
5.0.10.0030.0308.27
5.0.00.0030.0408.28
4.4.90.0030.0207.00
4.4.80.0100.0137.00
4.4.70.0030.0207.00
4.4.60.0030.0207.00
4.4.50.0030.0207.00
4.4.40.0030.0337.00
4.4.30.0030.0177.00
4.4.20.0000.0237.00
4.4.10.0030.0207.00
4.4.00.0030.0307.00
4.3.110.0030.0207.00
4.3.100.0070.0177.00
4.3.90.0030.0207.00
4.3.80.0070.0307.00
4.3.70.0000.0207.00
4.3.60.0000.0237.00
4.3.50.0070.0177.00
4.3.40.0000.0337.00
4.3.30.0000.0237.00
4.3.20.0000.0237.00
4.3.10.0000.0237.00
4.3.00.0130.0207.61

preferences:
42.8 ms | 401 KiB | 5 Q