son_encode替代函数php_json_encode
由于json_encode函数需要php5.20以上版本才支持,php不支持json_encode如何也用上json的功能呢?有没有什么替代函数,替代函数是没有的,不过有人做了一个自定义的php_json_encode,使用中会出现什么样的问题还未可知.
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;
}
}
if($pure_array)
{
$json_str ="[";
$temp = array();
for($i=0;$i {
$temp[] = sprintf("%s", php_json_encode($arr[$i]));
}
$json_str .= implode(",",$temp);
$json_str .="]";
}
else
{
$json_str ="{";
$temp = array();
foreach($arr as $key => $value)
{
$temp[] = sprintf(""%s":%s", $key, php_json_encode($value));
}
$json_str .= implode(",",$temp);
$json_str .="}";
}
}
else
{
if(is_string($arr))
{
$json_str = """. json_encode_string($arr) . """;
}
else if(is_numeric($arr))
{
$json_str = $arr;
}
else
{
$json_str = """. json_encode_string($arr) . """;
}
}
return $json_str;
}
function json_encode_string($in_str) {
mb_internal_encoding("UTF-8");
$convmap = array(0x80, 0xFFFF, 0, 0xFFFF);
$str = "";
for ($i = mb_strlen($in_str)-1; $i>=0; $i--) {
$mb_char = mb_substr($in_str, $i, 1);
if (mb_ereg("(\d+);", mb_encode_numericentity($mb_char, $convmap, "UTF-8"), $match)) {
$str = sprintf("\u%04x", $match[1]) . $str;
} else {
$str = $mb_char . $str;
}
}
return $str;
}
[/php]
json_encode替代函数php_json_encode

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

Video Face Swap
Échangez les visages dans n'importe quelle vidéo sans effort grâce à notre outil d'échange de visage AI entièrement gratuit !

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)
