时间:2021-07-01 10:21:17 帮助过:6人阅读
{
"CommunityModel": [
{
" UUID ": "xxxxxx-xxxxxx-xxxxxxx-xxxxxx1",
" CommunityName ": "格林花园",
" CommunityAddress ": "XXXX203号",
" Longitude ": "12.33333333",
" Latitude ": "143.1121222",
" Form ": "商品房",
" BuildingNum ": "100",
" OwnerNum ": "1800",
" CarportNum ": "1800"
},
{
" UUID ": "xxxxxx-xxxxxx-xxxxxxx-xxxxxx2",
" CommunityName ": "格林花园2",
" CommunityAddress ": "XX路203号",
" Longitude ": "12.33333333",
" Latitude ": "143.1121222",
" Form ": "商品房",
" BuildingNum ": "100",
" OwnerNum ": "1800",
" CarportNum ": "1800"
}
]
}
$url_get ='http://api.com:90/1.php';
$json=json_decode($this->curlGet($url_get));
foreach($json as $jsonvalue)
{
。。。。这里该如何写
// dump($jsonvalue);
}
$s =<<< JSON
{
"CommunityModel": [
{
" UUID ": "xxxxxx-xxxxxx-xxxxxxx-xxxxxx1",
" CommunityName ": "格林花园",
" CommunityAddress ": "XXXX203号",
" Longitude ": "12.33333333",
" Latitude ": "143.1121222",
" Form ": "商品房",
" BuildingNum ": "100",
" OwnerNum ": "1800",
" CarportNum ": "1800"
},
{
" UUID ": "xxxxxx-xxxxxx-xxxxxxx-xxxxxx2",
" CommunityName ": "格林花园2",
" CommunityAddress ": "XX路203号",
" Longitude ": "12.33333333",
" Latitude ": "143.1121222",
" Form ": "商品房",
" BuildingNum ": "100",
" OwnerNum ": "1800",
" CarportNum ": "1800"
}
]
}
JSON;
$a = json_decode($s, 1);
foreach($a['CommunityModel'] as $v) {
$arr[] = array('UUID' => $v[' UUID '], 'CommunityName' => $v[' CommunityName ']);
}
print_r($arr);
Array
(
[0] => Array
(
[UUID] => xxxxxx-xxxxxx-xxxxxxx-xxxxxx1