function parse_hex($string) {
    return preg_replace_callback(
        "(\\\\x([0-9a-f]{2}))i",
        function($a) {return chr(hexdec($a[1]));},
        $string
    );
}