Array push problem

I have this multi dimentional array:

{"sunday":{"open_a":null,"close_a":null,"open_b":null,"close_b":null},
"monday":{"open_a":"09:00:00","close_a":"09:30:00","open_b":null,"close_b":null},
"tuesday":{"open_a":"10:00:00","close_a":"12:30:00","open_b":null,"close_b":null},
"wednesday":{"open_a":"10:00:00","close_a":"13:00:00","open_b":null,"close_b":null},
"thursday":{"open_a":"10:00:00","close_a":"13:30:00","open_b":null,"close_b":null},
"friday":{"open_a":"11:00:00","close_a":"12:30:00","open_b":null,"close_b":null},
"saturday":{"open_a":null,"close_a":null,"open_b":null,"close_b":null}}

each weekday corresponds to another array in it…so,I want to push an additional member to this array and do something like that:

{"sunday":{"open_a":null,"close_a":null,"open_b":null,"close_b":null,"holiday":"yes"},
"monday":{"open_a":"09:00:00","close_a":"09:30:00","open_b":null,"close_b":null,"holiday":"no"},
...}

As you see I added another member(holiday).

How am I going to do it…I have tried various foreach array push combinations to achieve it.
I do not want to post them…there is no need.

that’s a JSON string, not a PHP array. otherwise array_replace() and the array union operator would work.

yes…you are right I am referring to a PHP array…despite the above form being in a JSON string.I do not understand though how array_replace() will help.Here is the PHP array(part of it):

array(3) {  ["sunday"]=>  array(4) {    ["open_a"]=>    NULL    ["close_a"]=>    NULL    ["open_b"]=>    NULL    ["close_b"]=>    NULL  }
  ....
  ["friday"]=>  array(4) { ["open_a"]=>string(8) "11:00:00",["close_a"]=>string(8) "12:30:00"["open_b"]=>
    NULL    ["close_b"]=>  NULL  }
  ["saturday"]=> array(4) { ["open_a"]=> NULL["close_a"]=> NULL["open_b"]=> NULL["close_b"]=>NULL
  }
}

Here is the second array:
array(2) { [0]=> string(6) "Friday" [1]=> string(8) "Saturday"}

probably it is my fault I did not said about this second array…
You see the goal here is add a holiday member(in the manner described to my first post) to first multiD array…in these members of it where the keys(which are weekdays) are in agreement with values of the second array.

For example as you see the second array contains Friday and Saturday and accordingly to these inner arrays in the multiD array must the holiday member must be added.

Sorry If I was not clear from the beginning

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.