Php Symfony2分割变量

Php Symfony2分割变量,php,arrays,symfony,twig,Php,Arrays,Symfony,Twig,我正在从事一个Symfony2项目,但这个问题可能仍然只适用于一般的php。我仍然在学习 我有一个url需要喜欢website.com/2014/fall/other。在symfony的小树枝模板中,我有website.com/{{{allsemests}}/other 我要传递的变量是 $allSemesters=array("Fall 2014", "Spring 2015", "Summer 2015"); 这是我的模板 {% for allSemester in allSemester

我正在从事一个Symfony2项目,但这个问题可能仍然只适用于一般的php。我仍然在学习

我有一个url需要喜欢
website.com/2014/fall/other
。在symfony的小树枝模板中,我有
website.com/{{{allsemests}}/other

我要传递的变量是

$allSemesters=array("Fall 2014", "Spring 2015", "Summer 2015");
这是我的模板

{% for allSemester in allSemesters %}
    <a href="{{ allSemester }}/other">{{ allSemester | capitalize }}</a>
{% endfor %}
{所有学期中所有学期的百分比%}
{%endfor%}
导致链接指向:
website.com/Spring%202015/other
,而不是
website.com/2015/Spring/other

有没有办法重新配置数组或以某种方式拆分变量以获得所需的url?非常感谢

您可以使用细枝过滤器


要使用.yml routing计算给定“季节”和“年份”参数的路线,我将执行以下操作:

semester_other:
    pattern: /{year}/{semester}/other/
    defaults: { _controller: "AppBlablaBundle:Semester:other", year: null, semester: null}
以及控制器:

public function otherAction($year, $semester) {

}

是的,我想我应该用正确的方法来实现这一点,并通过symfony path()传递变量。很好的电话,谢谢你的文档。
public function otherAction($year, $semester) {

}