this is my result $dataJson like this
$dataJson :
[
{
"42773": "2021-03-01",
"jumlah_bayar": 712584
},
{
"42792": "2021-03-01",
"jumlah_bayar": 795000
},
{
"42805": "2021-03-01",
"jumlah_bayar": 1536000
},
{
"42887": "2021-03-01",
"jumlah_bayar": 711566
},
{
"42773": "2021-03-01",
"jumlah_bayar": 712584
},
{
"42792": "2021-03-01",
"jumlah_bayar": 795000
}
]
$filter = [42792, 42805];
How to remove object whose key in date value is not available in $filter ? for example here I want to delete keys 42792 and 42805 in the form of an array in $filter
I've already tried, but there is still data left using this way :
(array)$filter= [42792];
for($i=0;$i<count($dataJson);$i++) {
foreach($dataJson[$i] as $key => $value) {
if(!in_array($key, $tmp_inv_id)) {
unset($dataJson[$i]);
}
}
}