given the following array:
Array
(
[0] => Array
(
[id_contract] => 1
[contract_months] => 5
[months_with_expenses] => 1
)
[1] => Array
(
[id_contract] => 2
[contract_months] => 12
[months_with_expenses] => 0
)
[2] => Array
(
[id_contract] => 3
[contract_months] => 1
[months_with_expenses] => 1
)
)
How can I remove all elements from the array where the key "contract_months" doesn't match the key "month_with_expenses"?
I'm using PHP.
Try this:
foreach ($array as $key => $element) {
if (conditions) {
unset($array[$key]);
}
}
You can try this :
foreach($arr as $key=>$value) {
if($value['contract_months'] != $value['months_with_expenses']) {
unset($arr[$key]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With