Home > Backend Development > PHP Tutorial > 如何解析json取值

如何解析json取值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:12:44
Original
992 people have browsed it

怎么解析json取值
{"weatherinfo":{"city":"岳阳","city_en":"yueyang","date_y":"2012年9月17日","date":"","week":"星期一"}}  

刚刚从c#换到php平台,语法不太熟悉,请问怎么解析这个json格式得到

岳阳
星期一

等数据。

------解决方案--------------------
$json = json_decode($str, TRUE);
var_dump($json);exit;

php 5.2后版本
------解决方案--------------------
但要注意:只支持 utf-8 编码
------解决方案--------------------
echo $json->weatherinfo->city;

Related labels:
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