3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "\xC4\xA2"; // The string is valid in all three encodings, so the first one listed will be returned var_dump(mb_detect_encoding($str, ['UTF-8', 'ISO-8859-1', 'ISO-8859-5'])); var_dump(mb_detect_encoding($str, ['ISO-8859-1', 'ISO-8859-5', 'UTF-8'])); var_dump(mb_detect_encoding($str, ['ISO-8859-5', 'UTF-8', 'ISO-8859-1']));

preferences:
27.68 ms | 405 KiB | 5 Q