树枝访问数组索引? [英] Twig Access Array Index?

查看:24
本文介绍了树枝访问数组索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从 Twig 模板中直接访问数组索引?

Is it possible to directly access an array index from within a Twig template?

这是我的设置,使用 Silex:

Here's my setup, using Silex:

return $app['twig']->render('template', array('numbers' => array('one', 'two', 'three')));

我可以做这样的事情吗?

so can I do something like this?

{{numbers[0]}}

推荐答案

就在发布这个之前我意识到,这正是你可以做的,但因为我没有在文档或谷歌的任何地方找到答案(纠正我,如果我错了),反正我已经发过了.

Just before posting this I realized, that's exactly what you can do, but as I didn't find the answer anywhere in the docs or google (correct me if I'm wrong), I've posted this anyway.

{{numbers[0]}} 

这篇关于树枝访问数组索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆