3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if(function_exists("json_encode")) { $table = get_html_translation_table(HTML_ENTITIES); $table = utf($table); echo json_encode(get_html_translation_table(HTML_ENTITIES)); } function is_utf($string) { return preg_match('%(?:[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+%xs', $string); } function utf($yolo) { if(is_array($yolo)) { $result = array(); foreach($yolo as $yo => $lo) $result[utf($yo)] = utf($lo); } elseif(is_string($yolo) && !is_utf($yolo)) $result = utf8_encode($yolo); else $result = $yolo; return $result; }