我有这样的yml配置:
test_array:
dinamic_key:
- 'this_is_value'
- 'it_is_also_a_value'
second_dinamic_key:
- 'yop, value'
- 'another value'
配置后,我想接收这样的数组:
$iNeedToGetArrayLikeThis = [
'dinamic_key' => [
'this_is_value',
'it_is_also_a_value'
],
'second_dinamic_key' => [
'yop, value',
'another value'
]
];
但我得到:
$whatIGet = [
[
'dinamic_key' => [
'this_is_value',
'it_is_also_a_value'
],
'second_dinamic_key' => [
'yop, value',
'another value'
]
],
];
我尝试使用->useAttributeAsKey()
,但是didint也起作用。
我的代码配置代码:
->children()
->arrayNode('test_array')
->ignoreExtraKeys(true)
->arrayPrototype()
->prototype('scalar')
->end()
->end()
->end()
->end()
->end()