3v4l.org

run code in 300+ PHP versions simultaneously
<?php function charset_decode_utf_8 ($string) { /* Only do the slow convert if there are 8-bit characters */ /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string)) return $string; // decode three byte unicode characters $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", \ "'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'", \ $string); // decode two byte unicode characters $string = preg_replace("/([\300-\337])([\200-\277])/e", \ "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'", \ $string); return $string; } $str = "Vanliga fr\u00e5gor"; $decoded_str = charset_decode_utf_8($str); print $decoded_str;

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)
5.4.290.0070.03912.51
5.4.280.0070.03612.41
5.4.270.0050.04112.41
5.4.260.0080.04512.41
5.4.250.0090.03912.41
5.4.240.0070.03612.41
5.4.230.0100.04512.40
5.4.220.0070.05012.40
5.4.210.0090.04712.40
5.4.200.0090.04912.40
5.4.190.0040.03912.40
5.4.180.0080.03512.40
5.4.170.0070.04012.40
5.4.160.0090.03512.40
5.4.150.0070.04312.40
5.4.140.0070.04912.09
5.4.130.0090.04512.07
5.4.120.0100.06012.04
5.4.110.0090.04912.03
5.4.100.0140.06112.03
5.4.90.0130.03912.03
5.4.80.0090.04712.03
5.4.70.0080.04912.02
5.4.60.0110.08012.03
5.4.50.0150.04612.03
5.4.40.0090.04712.01
5.4.30.0090.04912.01
5.4.20.0060.04412.00
5.4.10.0130.04512.01
5.4.00.0060.04611.50
5.3.280.0100.04012.71
5.3.270.0070.05612.72
5.3.260.0100.04912.72
5.3.250.0140.04912.72
5.3.240.0090.03812.72
5.3.230.0090.04312.70
5.3.220.0090.04512.68
5.3.210.0090.05112.68
5.3.200.0110.04912.68
5.3.190.0100.05512.68
5.3.180.0130.05412.67
5.3.170.0070.03812.67
5.3.160.0080.03912.68
5.3.150.0100.04312.67
5.3.140.0090.04812.66
5.3.130.0070.04612.66
5.3.120.0130.04712.65
5.3.110.0100.05312.66
5.3.100.0100.05012.12
5.3.90.0090.05612.11
5.3.80.0120.06312.09
5.3.70.0090.04512.09
5.3.60.0110.05312.08
5.3.50.0100.04112.03
5.3.40.0080.04512.03
5.3.30.0080.04511.98
5.3.20.0070.04711.76
5.3.10.0090.04211.74
5.3.00.0070.03911.72

preferences:
141.83 ms | 1394 KiB | 7 Q