Answer the question
In order to leave comments, you need to log in
How to write data to an array?
I need to display one order, one order can contain any number of products. I have one order displayed - one product, that is, one product in one order. And this order is duplicated in such quantity as the goods in this order.
foreach ($order as $item){
$arr = array(
' Новый заказ❗' => '',
' Товары: ' => $item['name'],
' Дата: ' => date('d.m.Y в H:i'),
' Управление заказами' => '<a href="https://stroymaz-beta.uz/admin/orders/new">Перейти</a>',
);
debug($arr);
}
Array
(
[ Новый заказ❗] =>
[ Товары: ] => Товар
[ Дата: ] => 17.04.2020 в 12:09
[ Управление заказами] => Перейти
)
Array
(
[ Новый заказ❗] =>
[ Товары: ] => Товар2
[ Дата: ] => 17.04.2020 в 12:09
[ Управление заказами] => Перейти
)
Array
(
[ Новый заказ❗] =>
[ Товары: ] => Товар3
[ Дата: ] => 17.04.2020 в 12:09
[ Управление заказами] => Перейти
)
Array
(
[ Новый заказ❗] =>
[ Товары: ] => Array
(
[0] => Товар
[1] => Товар2
[2] => Товар3
)
[ Дата: ] => 17.04.2020 в 12:15
[ Управление заказами] => Перейти
)
Answer the question
In order to leave comments, you need to log in
If I understood the question correctly, then in general terms I would do this:
1) in foreach, leave only the formation of an array of goods,
2) after the loop, create the desired array, substituting the one obtained in the first step into the goods (if I understood everything correctly, except for the goods, in item-ax is repeated).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question