3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toAscii($s) { static $transliterator = NULL; if ($transliterator === NULL && class_exists('Transliterator', FALSE)) { $transliterator = \Transliterator::create('Any-Latin; Latin-ASCII'); } $s = preg_replace('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u', '', $s); $s = strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06"); $s = str_replace( ["\xE2\x80\x9E", "\xE2\x80\x9C", "\xE2\x80\x9D", "\xE2\x80\x9A", "\xE2\x80\x98", "\xE2\x80\x99", "\xC2\xB0"], ["\x03", "\x03", "\x03", "\x02", "\x02", "\x02", "\x04"], $s ); if ($transliterator !== NULL) { $s = $transliterator->transliterate($s); } if (ICONV_IMPL === 'glibc') { $s = str_replace( ["\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"], ['>>', '<<', '...', 'TM', '(c)', '(R)'], $s ); $s = iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); $s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e" . "\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" . "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8" . "\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe" . "\x96\xa0\x8b\x97\x9b\xa6\xad\xb7", 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'); $s = preg_replace('#[^\x00-\x7F]++#', '', $s); } else { $s = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); } $s = str_replace(['`', "'", '"', '^', '~', '?'], '', $s); return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?'); } echo toAscii('ášěíáčšíěá');

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.0130.04722.16
8.3.50.0260.05123.97
8.3.40.0140.02422.59
8.3.30.0160.02522.64
8.3.20.0100.00723.51
8.3.10.0000.01625.44
8.3.00.0070.01027.14
8.2.180.0420.04920.18
8.2.170.0130.01722.96
8.2.160.0040.02624.01
8.2.150.0080.00824.18
8.2.140.0000.01625.48
8.2.130.0000.01626.16
8.2.120.0030.01423.23
8.2.110.0040.01525.70
8.2.100.0030.02121.72
8.2.90.0030.01721.84
8.2.80.0000.01921.97
8.2.70.0030.01721.68
8.2.60.0030.01621.91
8.2.50.0060.01321.63
8.2.40.0130.01023.99
8.2.30.0040.01524.05
8.2.20.0000.02021.87
8.2.10.0030.01621.82
8.2.00.0000.01921.99
8.1.280.0100.05225.92
8.1.270.0030.01325.80
8.1.260.0070.01126.35
8.1.250.0000.02028.09
8.1.240.0030.01627.32
8.1.230.0070.01826.57
8.1.220.0070.01321.52
8.1.210.0030.01721.39
8.1.200.0060.01521.23
8.1.190.0160.00820.88
8.1.180.0030.01721.15
8.1.170.0030.01622.71
8.1.160.0030.01622.40
8.1.150.0100.01023.80
8.1.140.0060.01323.37
8.1.130.0100.01022.52
8.1.120.0030.01621.39
8.1.110.0000.02421.34
8.1.100.0000.01921.29
8.1.90.0110.00921.27
8.1.80.0000.02421.25
8.1.70.0130.01021.40
8.1.60.0070.01321.48
8.1.50.0150.01221.34
8.1.40.0030.01721.48
8.1.30.0100.01021.55
8.1.20.0070.01421.57
8.1.10.0070.01321.54
8.1.00.0110.01421.29
8.0.300.0030.01623.44
8.0.290.0070.01320.63
8.0.280.0060.01221.96
8.0.270.0060.01221.06
8.0.260.0000.01821.02
8.0.250.0000.01820.96
8.0.240.0090.01720.90
8.0.230.0100.01620.82
8.0.220.0000.01920.87
8.0.210.0060.01520.91
8.0.200.0110.01121.00
8.0.190.0150.02220.96
8.0.180.0030.01720.94
8.0.170.0150.01220.86
8.0.160.0030.01720.85
8.0.150.0030.01720.75
8.0.140.0100.01720.96
8.0.130.0030.00313.67
8.0.120.0120.01220.94
8.0.110.0060.01621.10
8.0.100.0030.01721.04
8.0.90.0070.01421.04
8.0.80.0090.04121.13
8.0.70.0070.01421.09
8.0.60.0000.02021.02
8.0.50.0000.02021.24
8.0.30.0180.02721.34
8.0.20.0100.03821.43
8.0.10.0060.01521.11
8.0.00.0140.03320.90
7.4.330.0000.00515.55
7.4.320.0130.01020.33
7.4.300.0120.00720.41
7.4.290.0150.01520.42
7.4.280.0060.01920.47
7.4.270.0060.01620.45
7.4.260.0080.01920.47
7.4.250.0030.01720.68
7.4.240.0070.01320.71
7.4.230.0030.01720.74
7.4.220.0280.03720.81
7.4.210.0140.03420.70
7.4.200.0030.01820.61
7.4.160.0120.03020.69
7.4.150.0100.03320.71
7.4.140.0180.03620.64
7.4.130.0230.03320.63
7.4.120.0200.04320.72
7.4.110.0180.03520.47
7.4.100.0130.04120.48
7.4.90.0280.02820.48
7.4.80.0140.02820.58
7.4.70.0150.02920.28
7.4.60.0190.03920.42
7.4.50.0090.02820.59
7.4.40.0140.04320.47
7.4.30.0210.02120.51
7.4.20.0220.02220.34
7.4.10.0170.02620.41
7.4.00.0150.02319.78
7.3.330.0000.00513.57
7.3.320.0000.00513.46
7.3.310.0070.01420.48
7.3.300.0030.01720.47
7.3.290.0000.02020.61
7.3.280.0150.03620.56
7.3.270.0100.03320.55
7.3.260.0140.03220.51
7.3.250.0130.03520.62
7.3.240.0090.03220.55
7.3.230.0190.04120.70
7.3.210.0160.02620.44
7.3.200.0070.03820.59
7.3.190.0250.02520.58
7.3.180.0180.02520.70
7.3.170.0230.02120.55
7.3.160.0120.03120.44
7.3.150.0210.02520.50
7.3.140.0100.03820.44
7.3.130.0140.03320.67
7.3.120.0040.03820.39
7.3.110.0120.03320.59
7.3.100.0190.02620.52
7.3.90.0150.03020.34
7.3.80.0190.02520.44
7.3.70.0190.02720.57
7.3.60.0160.02720.39
7.3.50.0120.03320.50
7.3.40.0150.02920.64
7.3.30.0160.02720.46
7.3.20.0120.03120.30
7.3.10.0080.02920.63
7.3.00.0150.02020.69
7.2.330.0120.04020.75
7.2.320.0140.04120.87
7.2.310.0170.03220.70
7.2.300.0130.02920.71
7.2.290.0150.03420.72
7.2.280.0100.03320.70
7.2.270.0130.02920.48
7.2.260.0180.02720.84
7.2.250.0100.03620.54
7.2.240.0170.02720.80
7.2.230.0140.03020.73
7.2.220.0090.03520.64
7.2.210.0140.02920.52
7.2.200.0250.01920.44
7.2.190.0110.03320.59
7.2.180.0180.02520.68
7.2.170.0070.03420.57
7.2.160.0120.02820.62
7.2.150.0150.02720.65
7.2.140.0180.02720.77
7.2.130.0100.03020.71
7.2.120.0080.02920.75
7.2.110.0050.03120.65
7.2.100.0050.03220.68
7.2.90.0100.02620.75
7.2.80.0070.02920.77
7.2.70.0190.01820.89
7.2.60.0120.02320.79
7.2.50.0110.02920.80
7.2.40.0150.02920.72
7.2.30.0120.02820.70
7.2.20.0060.03120.77
7.2.10.0050.03120.65
7.2.00.0090.02420.83
7.1.330.0140.02919.25
7.1.320.0150.02519.68
7.1.310.0120.03119.46
7.1.300.0250.02019.56
7.1.290.0130.03319.42
7.1.280.0000.04319.52
7.1.270.0430.03319.37
7.1.260.0190.03219.48
7.1.250.0090.02819.59
7.1.240.0200.02019.55
7.1.230.0130.02919.29
7.1.220.0250.02219.38
7.1.210.0190.02519.27
7.1.200.0070.02819.49
7.1.190.0180.02719.28
7.1.180.0170.02819.49
7.1.170.0130.03219.66
7.1.160.0170.04119.39
7.1.150.0200.04119.72
7.1.140.0120.03119.55
7.1.130.0300.02019.50
7.1.120.0170.03019.48
7.1.110.0100.03119.35
7.1.100.0070.03319.68
7.1.90.0080.03519.57
7.1.80.0120.03019.58
7.1.70.0120.02720.50
7.1.60.0080.02720.65
7.1.50.0100.03019.39
7.1.40.0130.02819.28
7.1.30.0180.03419.30
7.1.20.0160.06431.92
7.1.10.0150.06122.90
7.1.00.0120.05522.78
7.0.330.0150.02819.13
7.0.320.0100.03018.91
7.0.310.0160.03219.10
7.0.300.0160.02719.12
7.0.290.0160.04519.32
7.0.280.0070.03219.18
7.0.270.0110.03018.91
7.0.260.0220.02819.00
7.0.250.0130.02619.20
7.0.240.0130.02619.34
7.0.230.0090.03119.32
7.0.220.0180.02119.43
7.0.210.0190.02519.30
7.0.200.0100.03720.21
7.0.190.0180.02219.33
7.0.180.0030.03519.30
7.0.170.0150.02719.05
7.0.160.0030.06422.66
7.0.150.0250.05622.48
7.0.140.0130.04922.63
7.0.130.0070.05522.49
7.0.120.0070.05422.35
7.0.110.0090.05922.30
7.0.100.0140.04922.41
7.0.90.0080.05422.48
7.0.80.0090.05222.50
7.0.70.0170.05022.45
7.0.60.0090.05322.49
7.0.50.0120.05222.52
7.0.40.0110.05022.47
7.0.30.0190.04622.49
7.0.20.0060.05522.48
7.0.10.0090.05422.48
7.0.00.0140.04822.46
5.6.400.0140.03419.88
5.6.390.0170.03019.71
5.6.380.0100.03719.78
5.6.370.0030.04619.72
5.6.360.0100.03919.73
5.6.350.0160.05119.88
5.6.340.0060.03519.96
5.6.330.0110.03319.52
5.6.320.0070.03519.93
5.6.310.0160.03219.78
5.6.300.0130.03219.71
5.6.290.0130.03319.83
5.6.280.0160.03219.77
5.6.270.0190.02719.63
5.6.260.0120.03319.64
5.6.250.0070.03719.99
5.6.240.0160.03219.93
5.6.230.0060.03519.79
5.6.220.0210.02719.79
5.6.210.0040.03919.89
5.6.200.0160.02619.91
5.6.190.0130.03319.99
5.6.180.0060.03919.95
5.6.170.0080.03619.59
5.6.160.0170.02919.62
5.6.150.0170.03019.65
5.6.140.0180.02919.45
5.6.130.0100.03619.77
5.6.120.0210.02919.51
5.6.110.0240.03019.71
5.6.100.0120.03819.61
5.6.90.0190.03019.48
5.6.80.0230.02319.50
5.6.70.0210.02819.69
5.6.60.0210.02919.70
5.6.50.0100.03619.70
5.6.40.0160.03219.77
5.6.30.0240.02119.64
5.6.20.0160.03119.39
5.6.10.0180.04819.57
5.6.00.0190.02819.59

preferences:
36.44 ms | 401 KiB | 5 Q