Home > Backend Development > PHP Tutorial > JSON转数组 获取有关问题

JSON转数组 获取有关问题

WBOY
Release: 2016-06-13 11:24:31
Original
1091 people have browsed it

JSON转数组 获取问题

<br /><?php<br /><br /><br />$cityArry = '[<br />        {<br />            "省": "台湾",<br />            "市": [<br />                {<br />                    "市名": "台北县",<br />                    "编码": "101340101"<br />                },<br />                {<br />                    "市名": "台中",<br />                    "编码": "101340401"<br />                }<br />            ]<br />        }<br />    ]';  <br /><br /><br />$temp1 = json_decode($cityArry);  <br /><br />$arr = array ($temp1);<br /><br />print_r($arr[0]);<br /><br />?><br />
Copy after login

我这个是 用json 转成数组
输出出来是:
Array ( [0] => stdClass Object ( [省] => 台湾 [市] => Array ( [0] => stdClass Object ( [市名] => 台北县 [编码] => 101340101 ) [1] => stdClass Object ( [市名] => 台中 [编码] => 101340401 ) ) ) )

我要的格式是
echo 编码=>城市

这样的数组我不知道怎么获取 省 市 编码了 有没有大神 能获取 这3种数据的呀
JSON 数组

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