PHP使用JSON通信
php中使用JSON的Code如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?php
header(
"Content-type: text/html; charset=utf-8"
);
$arr
=
array
(
array
(
"id"
=>1,
"name"
=>
"Nick"
,
"age"
=>39
),
array
(
"id"
=>2,
"name"
=>
"Tom"
,
"age"
=>26
)
);
$str
= json_encode(
$arr
);
echo
"JSON 数据<br>"
;
echo
$str
;
echo
"<br>"
;
echo
"将JSON数据转化为数组<br>"
;
$arr
= json_decode(
$str
);
print_r(
$arr
);
|
输出的结果如下图
本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/p/5911658.html,如需转载请自行联系原作者