我有一個JSON陣列看起來像這樣如何從PHP中的數組中取消設置值?
{
"id":"1507593152797237",
"handle":"naveen",
"firstName":"bos",
"lastName":"Hello",
"email":"[email protected]",
"pic":null,
"following":[
"123"
],
"followers":[
],
"groups":[
],
"blocking":[
],
"blockers":[
],
"postUnfollowing":[
],
"followingGroups":[
],
"likes":[
]
},
{
"id":"1234",
"handle":"naveesn.bos",
"firstName":"naveenbos",
"lastName":"boss",
"email":"[email protected]",
"pic":null,
"following":[
"123"
],
"followers":[
],
"groups":[
11
],
"blocking":[
],
"blockers":[
],
"postUnfollowing":[
],
"followingGroups":[
],
"likes":[
],
}
我想從這個數組等followingGroups [],阻滯劑[],阻斷[],
$響應=陣列(除去不需要的項目);
foreach ($user["followers"] as $follower) { $response[] = $this->mongologue->user('find', $follower); } echo json_encode($response);
我需要從$迴應取消設置不必要的東西,是指除去thsese事情followingGroups [],β受體阻滯劑[],阻止[3],請幫助。
上面的json對象數組創建自json_encode($ response);? json_encode($ response) –
@ShaunakShukla yes json_encode($ response) – Naveenbos
然後你可以在json_encode($ response)之前使用[Suman Biswas](http://stackoverflow.com/a/24490075/2679536)的答案。但在循環中!或者,在添加到$ response []之前,您可以在當前的foreach循環中保留條件! –