Answer the question
In order to leave comments, you need to log in
How to remove unnecessary iterations in nested foreach (Smarty)?
Array ($array):
array(1) {
[2014]=>
array(2) {
[7]=>
array(1) {
["rec"]=>
array(3) {
["accounts_count"]=>
string(1) "2"
["documents_count"]=>
string(1) "2"
["group_type"]=>
array(1) {
[0]=>
array(2) {
["value"]=>
string(1) "1"
["total_brutto"]=>
string(7) "5658.00"
}
}
}
}
[8]=>
array(1) {
["rec"]=>
array(3) {
["accounts_count"]=>
string(1) "1"
["documents_count"]=>
string(1) "1"
["ecmproducts_group_type"]=>
array(1) {
[0]=>
array(2) {
["value"]=>
string(1) "1"
["total_brutto"]=>
string(8) "12669.00"
}
}
}
}
}
}
{foreach from=$array key=year_key item=year}
{foreach from=$year key=month_key item=month}
{foreach from=$month key=type_key item=type}
{foreach from=$type.group_type key=group_type_key item=group_type name=group_type_name}
<p>{$group_type.value}</p> // Цыкл должен быть 2 раза, но происходит очень много лишних раз
{/foreach}
{/foreach}
{/foreach}
{/foreach}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question