码迷,mamicode.com
首页 > Web开发 > 详细

json_decode的替代函数

时间:2017-02-23 18:15:39      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:function   blog   als   comment   div   json   false   nbsp   str   

function json_decode2($json)
{
      $comment = false;
      $out = ‘$x=‘;
      for ($i=0; $i<strlen($json); $i++){
          if (!$comment){
              if (($json[$i] == ‘{‘) || ($json[$i] == ‘[‘)) $out .= ‘ array(‘;
              else if (($json[$i] == ‘}‘) || ($json[$i] == ‘]‘)) $out .= ‘)‘;
              else if ($json[$i] == ‘:‘) $out .= ‘=>‘;
              else $out .= $json[$i];
          }
          else $out .= $json[$i];
          if ($json[$i] == ‘"‘ && $json[($i-1)]!="\\") $comment = !$comment;
      }
      eval($out . ‘;‘);
      return $x;
}

 

json_decode的替代函数

标签:function   blog   als   comment   div   json   false   nbsp   str   

原文地址:http://www.cnblogs.com/LoveJulin/p/6434577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!