我用如下所示的YAML定义一个php数组
groups:
- 'Order'
- 'Adjustment'
- 'CarModel'
- 'Address'
- 'OrderItem'
- items:
- OrderItem
- Product
- product:
- Simple
- service:
- Simple
php伴侣是
$groups = [
'Order',
'Adjustment',
'CarModel',
'Address',
'OrderItem',
'items' => [
'OrderItem',
'Product',
'product' => ['Simple'],
'service' => ['Simple'],
]
];
Symfony将YAML格式转换为数字数组,而php是一个关联数组,即它们的array_keys是不同的。有什么方法可以在Symfony中用YAML定义关联数组?
答案 0 :(得分:1)
我自己找到了解决方法
groups:
0: 'Order'
1: 'Adjustment'
2: 'CarModel'
3: 'Address'
4: 'OrderItem'
items:
0: Product
1: Service
2: OrderItem
product: ['Simple']
service: [ 'Simple']