<!--PHP编程实战-->
<!--JSON & Ajax -->
<!--15-2-->
<!--将PHP嵌套数组编码为JSON格式,再解码为PHP数据类型-->
<?php
$books = array(
array("author" => "Lewis Carroll",
"title" => "Alice's Adventures in Wonderland",
"year" => 1865),
array("author" => "Yann Martel",
"title" => "Life of Pi",
"year" => 2001),
array("author" => "Junot Diaz",
"title" => "The Bried Wondours Life of Oscar Wao",
"year" => 2007),
array("author" => "JOseph Heller",
"title" => "Catch-22",
"year" => 1961),
array("author" => "Timothy Findley",
"title" => "Pilgrim",
"year" => 1999),
array("author" => "Fyodor Dostoyevsky",
"title" => "Brothers Karamazov",
"year" => 1880),
);
$json_books = json_encode($books);
$decoded_json_books = json_decode($json_books);
?>
<pre>
<?php var_dump($json_books); ?>
<?php var_dump($decoded_json_books) ?>
</pre>
PHP编程实战15-2
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 请求方法: {"GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS"}...
- 1、抗拒学英文 在国内几乎所的编程语言都是外国的,所以学技术必定要学会看英文文档,如果不学英文,是绝对无法从菜鸟转...