php实现json编码的方法,phpjson编码_PHP教程

WBOY
Release: 2016-07-13 09:45:33
Original
849 people have browsed it

php实现json编码的方法,phpjson编码

本文实例讲述了php实现json编码的方法。分享给大家供大家参考。具体如下:

<&#63;php
/*
 * json
 */
$books = array('key1'=>'value1','key2'=>'value2','key3'=>array('key4'=>'value4','key5'=>'value5'));
$json = json_encode($books);
$rejson = json_decode($json,true);
echo '原数组:<br/>';
print_r($books);
echo '<br/><br/>';
echo '经json编码后:<br/>';
print $json."<br/>";
echo '<br/>';
echo '经json解码后:<br/>';
print_r($rejson);
echo '<br/><br/>';
//实例
$jsonn = '{"error_code":"400","request":"\/Router\/aQConnectError","api_code":40006,"error":"\u4f20\u5165\u7684\u63a5\u53e3\u53c2\u6570\u51fa\u9519\uff0c\u53c2\u6570openid\u672a\u8bbe\u5b9a\u3002"}';
print_r(json_decode($jsonn));
&#63;>

Copy after login

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1040813.htmlTechArticlephp实现json编码的方法,phpjson编码 本文实例讲述了php实现json编码的方法。分享给大家供大家参考。具体如下: php/* * json */$books = array('key...
Related labels:
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 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!