Answer the question
In order to leave comments, you need to log in
How to merge identical arrays?
Hello. I can not exactly formulate my question, so I ask you for help in solving my problem. I work with the smarty templating engine.
We have an array like:
array(3) {
["order_num"]=>
string(4) "1"
["price"]=>
string(7) "1200.00"
["title"]=>
string(61) "Майка""
}
array(3) {
["order_num"]=>
string(4) "2"
["price"]=>
string(6) "130.00"
["title"]=>
string(63) "Футболка"
}
array(3) {
["order_num"]=>
string(4) "2"
["price"]=>
string(6) "350.00"
["title"]=>
string(71) "Трусы"
}
<table>
{foreach $order_report_arr as $nums}
<pre>
{var_dump($nums)}
</pre>
<tr>
<td>Номер заказа {$nums.order_num}</td>
</tr>
<tr>
<td>Название {$nums.title}</td>
<td>Цена {$nums.price}</td>
</tr>
{/foreach}
</table>
Answer the question
In order to leave comments, you need to log in
group orders by number in puff, in the template just output in cycles.
Where have all the comments gone? Here is an almost ready-made version, but how to access the desired variable here?
<table>
{foreach $order_report_arr as $nums}
<tr>
<td>Номер заказа {$nums.order_num}</td>
</tr>
{foreach $nums as $num}
<tr>
<td>Название {$num}</td>
</tr>
{/foreach}
{/foreach}
</table>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question