I have a multidimensional associative array and im using two foreach to iterate them, i need to change a value from the original array, here a representation of my code and what ive tried:
$array = [
['id' => 1, 'customers' => [['customerName' => 'Daniel', 'age' => 20, 'isYoung' => false], ['customerName' => 'Patrick', 'age' => 56, 'isYoung' => false]]],
['id' => 4, 'customers' => [['customerName' => 'Paul', 'age' => 41, 'isYoung' => false]]]
];
foreach($array as $key => $value) {
foreach($value['customers'] as $sKey => $sValue {
if($sValue['age'] < 35) {
$array[$key]['customers'][$sKey]['isYoung'] = true; //Doesnt Work
$value['customers'][$sKey]['isYoung'] = true; //Doesnt Work
}
}
}
Any leads?