日期:2014-05-17 浏览次数:20649 次
<?php
$cityArry = '[
{
"省": "台湾",
"市": [
{
"市名": "台北县",
"编码": "101340101"
},
{
"市名": "台中",
"编码": "101340401"
}
]
}
]';
$temp1 = json_decode($cityArry);
$arr = array ($temp1);
print_r($arr[0]);
?>
$arr = json_decode($cityArry, true);
foreach($arr[0] as $key=>$item) {
echo $item['省'], PHP_EOL;
foreach($item['市'] as $row) {
echo "$row[编码] => $row[市名]\n";
}
}