$c=0;
foreach ($n as $keys => $values) {
$c++;
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["ID"] = $values["ID"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["NAME"] = $values["NAME"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_PICTURE"] = $values["DETAIL_PICTURE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT"] = $values["DETAIL_TEXT"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT_TYPE"] = $values["DETAIL_TEXT_TYPE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["IMAGE_URL"] = $values["IMAGE_URL"];
}
}
Array
(
[0] => Array
(
[ID] => 1366
[NAME] => Завтрак
[UF_TIME] => Array
(
[0] => 10:00
)
[SUBCATEGORY] => Array
(
[0] => Array
(
[ID] => 1782
[NAME] => Закуски острые
[UF_MAX_CHOOSEN_BLUD] => 1
[PRODUCTS] => Array
(
[172] => Array
(
[ID] => 2002
[NAME] => test1
[PREVIEW_PICTURE] => 417
[PREVIEW_TEXT] =>
[PREVIEW_TEXT_TYPE] => text
[IMAGE_URL] => http://emcq.zapusq.ru/upload/iblock/659/food-12.png
)
[178] => Array
(
[ID] => 2017
[NAME] => test14
[PREVIEW_PICTURE] =>
[PREVIEW_TEXT] =>
[PREVIEW_TEXT_TYPE] => text
[IMAGE_URL] => http://emcq.zapusq.ru
)
)
)
...
foreach ($n as $values) {
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][] = $values;
}
}
foreach ($n as $keys => $values) {
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["ID"] = $values["ID"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["NAME"] = $values["NAME"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_PICTURE"] = $values["DETAIL_PICTURE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT"] = $values["DETAIL_TEXT"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT_TYPE"] = $values["DETAIL_TEXT_TYPE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["IMAGE_URL"] = $values["IMAGE_URL"];
$c++;
}