Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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
Php 如何使用symfony/config解析数组的数组?_Php_Symfony_Symfony Components - Fatal编程技术网

Php 如何使用symfony/config解析数组的数组?

Php 如何使用symfony/config解析数组的数组?,php,symfony,symfony-components,Php,Symfony,Symfony Components,我要分析此结构的配置: $config = [ 'streams' => [ 'foo' => [ [ 'id' => 'some-identifier', 'type' => 'a', ], [ 'id' => 'some-other-identifier',

我要分析此结构的配置:

$config = [
    'streams' => [
        'foo' => [
            [
                'id' => 'some-identifier',
                'type' => 'a',
            ],
            [
                'id' => 'some-other-identifier',
                'type' => 'b',
            ],
        ],
        'bar' => ...,
    ],
];
在这个数组中,
streams
是一个预定义的键,包含多个任意命名流的映射。在这种情况下,有两个流被定义为
foo
bar

每个流都有一个处理程序数组。每个处理程序都是一个具有两个属性的映射:
id
type

我的结局是:

$rootNode
    ->children()
        ->arrayNode('streams')
            ->prototype('array')
                ->children()

                ->end()
            ->end()
        ->end()
    ->end()
;
现在我陷入了下一步的困境

如果我用英语解释的话,它将是:
streams
是一个映射数组的映射

用我的代码,我可以把它表达成“是一张地图”和如何说它是“数组”

有什么提示吗?

就是这样

$rootNode
    ->children()
        ->arrayNode('streams')
            ->prototype('array')
                ->prototype('array')
                    ->children()
                        ->scalarNode('id')->end()
                        ->scalarNode('type')->end()
                    ->end()
                ->end()
            ->end()
        ->end()
    ->end()
;
请注意,外部
原型('array')
没有
子项()