Home > 类库下载 > PHP类库 > body text

son_encode alternative function php_json_encode

高洛峰
Release: 2016-10-14 10:37:34
Original
1338 people have browsed it

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

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!