json encode alternative

Solutions on MaxInterview for json encode alternative by the best coders in the world

showing results for - "json encode alternative"
Esther
26 Jan 2019
1
2For PHP5.3 users who want to emulate JSON_UNESCAPED_UNICODE, there is simple way to do it:
3<?php
4function my_json_encode($arr)
5{
6        //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding
7        array_walk_recursive($arr, function (&$item, $key) { if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); });
8        return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
9
10}
11?>
12
13
similar questions
queries leading to this page
json encode alternative