I know that this is a similar question: Updating a Multidimensional Array in PHP
but is different my problem:
I have a multidimensional array and I want to check if a value inside it is equal another, if tue update value.
I have tried in this way:
$room_id = '1205222__1763659__386572_1';
foreach($cart as $c){
if($c['item_type'] == 'hotel'){
foreach($c as $key => $value){
if(substr($key, 0, 7) == 'room_id'){
if($value == $room_id) {
$c[$key] = '';
}
}
}
}
}
This is an example of my array:
array() {
[0]=>
array() {
["item_type"]=> "hotel"
["room_id_0"]=> "1205222__1763659__386572_1"
["room_id_1"]=> "1205222__1763659__386572_2"
},
[1]=>
array() {
["item_type"]=> "hotel"
["room_id_0"]=> "1205222__1763659__386572_3"
["room_id_1"]=> "1205222__1763659__386572_4"
}
}
I have checked if the conditions work right and yes, but when I make the assignment and after print the array again the array isn't changed.
Can someone help me?
Thanks