求问smarty输出二维数组的问题
$Product=Array([ProductModelii]=>Array([0]=>E63371[1]=>R33371[2]=>E63371E1-H[3]=>6337...
$Product=Array
(
[ProductModelii] => Array
(
[0] => E63371
[1] => R33371
[2] => E63371E1-H
[3] => 63371E1-
)
[SizeSmallpicii] => Array
(
[0] => ../upload/product/ym/small%2F3D%2FD%2D3E63371%%2Ejpg
[1] => ../upload/product/ym/small%2F3D%2FD%%2Ejpg
[2] => ../upload/product/ym/small%2F3D%2FD%%2DH%2870X300%29%2Ejpg
[3] => ../upload/product/ym/small%2F3D%%2DWH%28330X600%29%2Ejpg
)
[SizeBigpicii] => Array
(
[0] => ../upload/product/ym%2F3D%2FD%2D3E63371%2FD%3371%2Ejpg
[1] => ../upload/product/ym%2F3D%2FD%2D3E63371%2F2%R371%2Ejpg
[2] => ../upload/product/ym%2F3D%2FD%2D3E63371%2FD2870X300%29%2Ejpg
[3] => ../upload/product/ym%2F3D%2FD%%2DWH%28330X600%29%2Ejpg
)
)
数组如上,smarty模板里,我需要这样循环输出:
<UI>
<li>
型号:<div>这里输出型号,如上面数组里面的[ProductModelii][0]</div>
小图:<div>这里输出小图,如上面数组里面的[SizeSmallpicii][0]</div>
大图:<div>这里输出图,如上面数组里面的[SizeBigpicii][0]</div>
</li>
<li>
型号:<div>这里输出型号,如上面数组里面的[ProductModelii][1]</div>
小图:<div>这里输出小图,如上面数组里面的[SizeSmallpicii][1]</div>
大图:<div>这里输出图,如上面数组里面的[SizeBigpicii][1]</div>
</li>
<li>
.............................
</li>
</UI>
像上面这样输出,在smarty里面怎么写呢,小弟弄了一天,都搞不好,求助啊 展开
(
[ProductModelii] => Array
(
[0] => E63371
[1] => R33371
[2] => E63371E1-H
[3] => 63371E1-
)
[SizeSmallpicii] => Array
(
[0] => ../upload/product/ym/small%2F3D%2FD%2D3E63371%%2Ejpg
[1] => ../upload/product/ym/small%2F3D%2FD%%2Ejpg
[2] => ../upload/product/ym/small%2F3D%2FD%%2DH%2870X300%29%2Ejpg
[3] => ../upload/product/ym/small%2F3D%%2DWH%28330X600%29%2Ejpg
)
[SizeBigpicii] => Array
(
[0] => ../upload/product/ym%2F3D%2FD%2D3E63371%2FD%3371%2Ejpg
[1] => ../upload/product/ym%2F3D%2FD%2D3E63371%2F2%R371%2Ejpg
[2] => ../upload/product/ym%2F3D%2FD%2D3E63371%2FD2870X300%29%2Ejpg
[3] => ../upload/product/ym%2F3D%2FD%%2DWH%28330X600%29%2Ejpg
)
)
数组如上,smarty模板里,我需要这样循环输出:
<UI>
<li>
型号:<div>这里输出型号,如上面数组里面的[ProductModelii][0]</div>
小图:<div>这里输出小图,如上面数组里面的[SizeSmallpicii][0]</div>
大图:<div>这里输出图,如上面数组里面的[SizeBigpicii][0]</div>
</li>
<li>
型号:<div>这里输出型号,如上面数组里面的[ProductModelii][1]</div>
小图:<div>这里输出小图,如上面数组里面的[SizeSmallpicii][1]</div>
大图:<div>这里输出图,如上面数组里面的[SizeBigpicii][1]</div>
</li>
<li>
.............................
</li>
</UI>
像上面这样输出,在smarty里面怎么写呢,小弟弄了一天,都搞不好,求助啊 展开
展开全部
{foreach name=outer item=contact from=$contacts}
{foreach key=key item=item from=$contact}
{$key}: {$item}<br>
{/foreach}
{/foreach}
循腔皮环·套 循环团圆键塌巧
{foreach key=key item=item from=$contact}
{$key}: {$item}<br>
{/foreach}
{/foreach}
循腔皮环·套 循环团圆键塌巧
更多追问追答
追问
哥们,我要相对应的输出位置哦,像你这样,你的UI和LI就没效果了哦。能否告诉我,在我的LI里面怎么写吗?
追答
{foreach key=key item=it from=$Product.ProductModelii}
型号:这里输出型号,如上面数组里面的{$Product.ProductModelii->key}
小图:这里输出小图,如上面数组里面的{$Product.SizeSmallpicii->key}
大图:这里输出图,如上面数组里面的{$Product.SizeBigpicii->key}div>
{/foreach}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询