Array push problem

I have this multi dimentional array:


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


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.