php_json入库有关

php入库json信息 有些字符需要特殊处理

 

 1 //组装
 2       $test=array();
 3      $test["k1"]= urlencode($k1);
 4      $test["k2"]=urlencode($k2);
 5      $test["k3"]=urlencode($k3);
 6      $test= urldecode(json_encode($test));
 7      echo $test."\n";
 8      //exit;
 9 //入库处理
10      $sql="update tblTest set test=unhex('".bin2hex($test)."')  where sid="."'$sid'";
11      mysql_query($sql);
12               
13               
14     //解析
15                $obj=json_decode($content,true);
16                 $k1=$obj['k1'];
17                 $k2=$obj['k2'];
18                 $k3=$obj['k3'];

 

posted @ 2015-04-10 18:37  cphmvp  阅读(328)  评论(0编辑  收藏  举报
爬虫在线测试小工具: http://tool.haoshuju.cn/