[英]How to print values in an array in a twig in symfony 2?
我正在将以下两个二维数组传递给我的树枝。
Array (
[0] => Array ( [restaurantname] => Pizza Hut
[restaurantaddress] => Union Place
[restauranttelephone] => 5555522255
[mstrestaurantstatusid] => 1
[restaurantid] => 1 )
[1] => Array ( [restaurantname] => The Coffee Bean
[restaurantaddress] => Maitland Crescent
[restauranttelephone] => 3333569855
[mstrestaurantstatusid] => 1
[restaurantid] => 2 )
)
在我的树枝上,我只想打印餐厅名称。 但是稍后我将使用其他信息。 我在仅打印餐厅名称时遇到了麻烦。 请帮忙。 谢谢。
Twig中的数组是一个关联数组。 为了获得相对值,必须在方篮中指定一个键,如下所示:
{{ arrayName['key'] }}
就您而言,您只需将restaurantname
传递为数组的键即可:
{{ arrayName['restaurantname'] }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.