Example #1
0
function fn_exim_prepare_data_to_convert($data)
{
    $_data = array();
    if (is_array($data) && is_callable('mb_encode_numericentity')) {
        foreach ($data as $k => $v) {
            $key = mb_encode_numericentity($k, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
            if (is_array($v)) {
                $_data[$key] = fn_exim_prepare_data_to_convert($v);
            } else {
                $_data[$key] = mb_encode_numericentity($v, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
            }
        }
    } else {
        $_data = $data;
    }
    return $_data;
}
Example #2
0
 public function fn_exim_json_encode($data)
 {
     if (is_callable('mb_encode_numericentity') && is_callable('mb_decode_numericentity')) {
         $_data = fn_exim_prepare_data_to_convert($data);
         return mb_decode_numericentity(json_encode($_data), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
     } else {
         return json_encode($data);
     }
 }