Answer the question
In order to leave comments, you need to log in
How to form an array for writing in xls?
Hello !
There are two arrays, one with a list of users (the IDs of the infoblock elements are in UF_SELECT_MON, UF_SELECT_TUE):
Array
(
[0] => Array
(
[ID] => 98
[NAME] => Иванов
[LAST_NAME] => Иван
[UF_SELECT_MON] => Array
(
[0] => 1362
)
[UF_SELECT_TUE] => Array
(
[0] => 1362
[1] => 1363
)
[UF_SELECT_WED] => Array
(
[0] => 1362
[1] => 1363
)
[UF_SELECT_THU] => Array
(
[0] => 1362
[1] => 1363
)
[UF_SELECT_FRI] => Array
(
[0] => 1362
)
[UF_SELECT_SAT] => Array
(
[0] => 1362
)
[UF_SELECT_SUN] => Array
(
[0] => 1362
[1] => 1363
)
[UF_ADDRESS] => 1374
)
[1] => Array
(
[ID] => 1
[NAME] => Иванов
[LAST_NAME] => Иван
[UF_SELECT_MON] => Array
(
[0] => 1880
[1] => 1941
)
[UF_SELECT_TUE] => Array
(
[0] => 1941
[1] => 1921
)
[UF_SELECT_WED] => Array
(
[0] => 1846
[1] => 1842
)
[UF_SELECT_THU] => Array
(
[0] => 1968
[1] => 1921
[2] => 1963
)
[UF_SELECT_FRI] => Array
(
[0] => 1845
[1] => 1931
[2] => 1846
[3] => 1856
[4] => 1973
[5] => 1886
)
[UF_SELECT_SAT] => Array
(
[0] => 1880
[1] => 1845
[2] => 1941
)
[UF_SELECT_SUN] => Array
(
[0] => 1845
[1] => 1995
[2] => 1971
[3] => 1937
[4] => 1855
[5] => 1852
[6] => 1871
[7] => 1929
[8] => 1974
[9] => 1903
[10] => 1870
[11] => 1975
[12] => 1966
)
[UF_ADDRESS] => 1373
)
Array
(
[1842] => Джем порц.
[1845] => Банан 1 шт
[1846] => Груша 1 шт
[1852] => Каша из полбы
[1855] => Каша гречневая на молоке без лактозы
[1856] => Каша овсянная на молоке без лактозы
[1862] => Блинчики с творогом 140/24г
[1863] => Омлет с овощами (новый)
[1870] => Морс брусничный 0,2
[1871] => Компот яблочно-вишневый 0,2
[1880] => Багет
[1886] => Лимонад фруктовый
[1903] => Микс салат с моцареллой
[1921] => Борщ с говядиной 200/30г
[1929] => Котлета из трески с петрушкой и соусом бешамель
[1931] => Бефстроганов
[1937] => Картофельное пюре на безлактозном молоке
[1941] => Баранина тушеная с рагу из баклажанов и кабачков 260/15
[1963] => Брокколи на пару
[1966] => Овощное соте 120г
[1968] => Боллы куриные с зеленью и брокколи
[1971] => Индейка су-вид 110Г
[1973] => Каша рисовая с яблоком на воде
[1974] => Кролик в собственном соку 120г
[1975] => Овощи на пару
[1995] => Зефир яблоко
)
Answer the question
In order to leave comments, you need to log in
$users = ...;
$products = ...;
$days = [
'Понедельник' => 'UF_SELECT_MON',
...
];
$excelRows = [];
foreach ($users as $user) {
foreach ($days as $label => $field) {
$userDayProductsLabels = [];
$userDayProducts = $user[$field];
foreach ($userDayProducts as $id) {
$userDayProductsLabels[] = $products[$id];
}
if (empty($userDayProductsLabels)) {
continue;
}
$excelRows[] = [
$user['NAME'],
$label,
join(", ", $userDayProductsLabels),
];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question