我所需的内容:
以下为字符串:
以下为字符串:
what i Need:
["Product_Name"]=> string(362) "Top End Transport System,Band Combiner Devices,Our Mid Level Transport System,The Introductory Transport System,In-Line Amplification Systems,Intelligent Ethernet Access System,Ethernet Access System,Intelligent Ethernet Access System (Ieas 05),Intelligent Ethernet Access System (Ieas 06),Intelligent Ethernet Access System (Ieas 03),Ethernet Aggregation Device" }
- 我正在使用php的slice函数,以便验证字符串到第5个字符串。
- 例如:顶级传输系统,您的中级传输系统,介绍性传输系统,线内放大系统,智能以太网访问系统。
- 我需要前五个字符串。
- 我已经参考了文章 http://twig.sensiolabs.org/doc/filters/split.html
这是Twig代码:
{% set foo = item.Product_Name|split(',') %}
{{ dump (foo) }}
{% for i in item.Product_Name|slice(0, 5) %}
{{ dump(i) }}
{% endfor %}
- slice函数是用于数组的,因此,请告诉如何在twig中将产品名称转换为数组