Home  >  Article  >  类库下载  >  son_encode alternative function php_json_encode

son_encode alternative function php_json_encode

高洛峰
高洛峰Original
2016-10-14 10:37:341330browse

Since the json_encode function requires php5.20 or above to be supported, how can we use the json function if php does not support json_encode? Is there any alternative function? There is no alternative function. However, someone has made a custom php_json_encode. It is not known what problems will occur during use.

http://www.php.net/manual/zh /function.json-encode.php#74878

[php]
function php_json_encode($arr)
{
$json_str = "";
if(is_array($arr))
{
$pure_array = true;
$array_length = count($arr);
for($i=0;$i {
if(! isset($arr[$i]))
{
$pure_array = false;
                 break; 0;$i               $temp[] = sprintf("%s", php_json_encode($arr[$i])); S}
else} {
$ json_Str = "{";
$ temp = array ();
Foreach ($ arr as $ key => $ value) {
$ temp [] = sprintf ; {
if(is_string($arr))                              $json_str                                                                                   ;
}
Else
{
$ json_str = "" "" "" "" "" "" ";" ""; ""; "";
}
Return $ json_str;
}











Ternal_encoding ("UTF-8 ");
$convmap = array(0x80, 0xFFFF, 0, 0xFFFF);
$str = "";
for ($i = mb_strlen($in_str)-1; $i>=0; $i--) {
                                                                                                                                                            {
            $str = sprintf("u%04x", $match[1]) . $str;
                                                                                                                       $str

[ /php]

json_encode alternative function php_json_encode

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more