如何转换数组成智者模板逗号分隔字符串? [英] How to convert an array into comma separated strings in smarty template?
本文介绍了如何转换数组成智者模板逗号分隔字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有标题为 $preview_data code>分配给Smarty模板如下数组:
I've an array titled $preview_data
assigned to smarty template as follows:
Array
(
[applicable_states] => Array
(
[0] => 1
[1] => 3
[2] => 4
[3] => 10
[4] => 11
)
)
现在我想说明上述数组元素为逗号分隔值在智者模板的div元素。总之,应该表现得像破灭()在PHP。是否有人可以帮助我在智者的模板实现这一目标?提前致谢。
Now I want to show the above array elements as comma separated values in a div element of a smarty template. In short it should behave like implode() in php. Can someone please help me in achieving this in smarty template? Thanks in advance.
推荐答案
试试这个:
{', '|implode:$preview_data.applicable_states}
它会给你你期待什么。干杯!
It will give you what you are expecting. Cheers!!!
这篇关于如何转换数组成智者模板逗号分隔字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文