As from a php array to do a javascript array?

There is a component in which to build a php array, then in the template of this component of this array are the data. In this array are the coordinates I it is necessary map to build. Here is an example of the array.
[OFFICE] => Array
(
 [0] => Array
(
 [PRICE] => 260
 [DAY] => 2 days
 [COMPANY] => SDEK
 [NAME] => parcel - to the point of issuance
 [STRAH] => 0
 [ID] => 37
 [PRICEHASH] => -1
 [TRANSFER] => 0
 [OFFICE] => Array
(
 [0] => Array
(
 [id] => 449
 [to_tarif] => 37
 [code] => MSK2
 [name] => St. Sergius of Radonezh, D. 29/31
 [address] => St. Sergius of Radonezh, D. 29/31
 [tel] => +7-910-487-50-57, +7-925-859-03-65
 [schedule] => mon.-PT. from 10:00 to 20:00, Saturday from 10:00 to 18:00, sun. from 10:00 to 16:00
 [gps] => 37.679275,55.747010
)

 [1] => Array
(
 [id] => 3252
 [to_tarif] => 37
 [code] => MSK17
 [name] => the Shchelkovo highway, d. 29
 [address] => Schelkovskoe highway, 29
 [tel] => +7-901-757-85-06
 [schedule] => mon.-PT. from 10:00 to 20:00, sat.-sun. from 10:00 to 16:00
 [gps] => 37.780500,55.810200
)
)
)
)

At the end of the template I process map. The data planned to take out groups.
var myMap;
 function init (ymaps) {
 myMap = new ymaps.Map("map", {
 center: [50.443705, 30.530946],
 zoom: 16
});
 for (var i = 0, l = groups.length; i < l; i++) {
createGroup(groups[i]);
}
 function createGroup (group) {
......
}
myMap.setBounds(myMap.geoObjects.the getBounds());
 };

That should look like groups
var groups = [
{
 name: "Famous monuments",
 style: "islands#redIcon",
 items: [
{
 center: [50.426472, 30.563022],
 name: "Monument"
},
{
 center: [50.45351, 30.516489],
 name: "Monument"
},
{
 center: [50.454433, 30.529874],
 name: ARKA
}
]},
 ];

How can I from php array to this groups?
Tried here so, but does not work.
var groups = [
 <?foreach ($arResult["OFFICE"] as $item):?>
{
 name: <?=$item["NAME"]?>,
 style: "islands#redIcon",
 items: [
 <?foreach ($item["OFFICE"] as $value):?>
{
 center: [<?=$value["gps"]?>],
 name: <?=$value["address"]?>
},
<?endforeach;?>
]},
<?endforeach;?>
 ];
March 12th 20 at 07:58
2 answers
March 12th 20 at 08:00
Solution
1. Given source array to the desired appearance level php

2. Sent to js
var groups = <?= json_encode($phpArray) ?>;
March 12th 20 at 08:02
Solution
Convert php array into json (json_encode($array))
Convert on the javascript side the array from the json (the JSON.parse())

Find more questions by tags JavaScriptPHP