How to write loops in Smarty templates
A half-day tutorial was studied, as if all the loops were for the incoming array
My question is this:
In an incoming array, 8 elements are named from I0 to i7, and now the 8 elements need to be processed
Because this array also contains other elements, it cannot be recycled for arrays
I think it's something like this.
for ($i =0; $i < 8; $i + +)
{
echo $arr ["i$i"];
}
I embed this PHP code in Smarty, and the result seems to be to get the variable $arr, resulting in no output.
Do not know this in the smarty how to achieve, please expert guidance
------Solution--------------------
There's another way of thinking. You can write the array on the PHP page, which is i0-i7, and then loop through the array, where the data is printed.
Like the array you passed is $i.
PHP code
{foreach from= $i item=item}{$arr [$item]}
--- ---solution--------------------
PHP code
foreach (from= $arr; Key=k item=v) {key: {$k}: value {$v}}
------solution--------------------
{section name= "fooo" loop= $new _re_j}
{$new _re _id[fooo]}
{/section}
------solution--------------------
Nesting loops in Smarty
------ Solution--------------------
Section foreach Loop;
------Solution--------------------
{foreach from= $i item= Item}
{$arr [$item]}
------Solution--------------------
Why do you do it in Smarty? Is it better to finish working in PHP and then output array display?
------Solution--------------------
Smarty templates are typically looped with foreach
{{foreach from= $test key=key item=i}}
{{/foreach}}