I have this variable $office which will output when print_r:
{
"total": 3,
"results": [
{
"id": "4",
"blog_id": "11",
"office_name": "Japan",
"office_status": "inactive"
},
{
"id": "5",
"blog_id": "11",
"office_name": "USA",
"office_status": "active"
},
{
"id": "6",
"blog_id": "11",
"office_name": "London",
"office_status": "inactive"
},
}
}
Now I want to create a new variable where the one with office_status of active will only show up, my desired output is:
{
"total": 1,
"results": [
{
"id": "5",
"blog_id": "11",
"office_name": "",
"office_status": "active"
},
}
}
This is what I tried so far but it still returns all of the array:
$v= "active";
$k = "office_status";
foreach($offices as $k => $v) {
$offices_active[$k] = array_filter($v);
}
print_r($offices_active);
Please help. Thank you