关联数组中的数组

时间:2014-07-17 09:53:37

标签: symfony yaml

我试图在yml中实现这样的结构:

$admin_menu_items = array(
    array(
        "label" => "thisisalabel"
        "sub_menu_items" => array(
             array("label" => "anotherlabel", "route" => "routename"),
             array("label" => "thirdlabel", "route" => "anotherroutename")
        )
    )
);

到目前为止,我已经尝试过这个但没有成功:

admin_menu_items:
    - { label: "thisisalabel", sub_menu_items:
        - { label: "anotherlabel", route: "routename" }
        - { label: "thirdlabel", route: "anotherroutename" }
    }

你能帮助我找出正确的方法吗?

最后,我根据Qoop的答案使用了溶剂。这是:

admin_menu_items:
    -
        label: "thisisalabel"
        sub_menu_items:
            - { label: "anotherlabel", route: "routename" }
            - { label: "thirdlabel", route: "anotherroutename" }

1 个答案:

答案 0 :(得分:1)

我认为这可能会这样做..

admin_menu_items:
    -
        label: "thisisalabel"
        sub_menu_items:
            -
                label: "anotherlabel"
                route: "routename"
            -
                label: "thirdlabel"
                route: "anotherroutename"