Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony 关联数组中的数组_Symfony_Yaml - Fatal编程技术网

Symfony 关联数组中的数组

Symfony 关联数组中的数组,symfony,yaml,Symfony,Yaml,我试图在yml中实现这样的结构: $admin_menu_items = array( array( "label" => "thisisalabel" "sub_menu_items" => array( array("label" => "anotherlabel", "route" => "routename"), array("label" => "thirdlabe

我试图在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" }

我想这可能行

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

最后,我使用了一个类似的解决方案,并以此为基础。我不理解第一段代码是用什么语言编写的,但它说了五遍“array”。我有点期待,但在YAML中没有看到五个有序列表。第二、第四和第五个“数组”是否生成无序散列或键值对的有序列表?此外,如果$admin_menu_项表示变量名而不是哈希表中的键,则第一行可能不属于YAML。