我有一个这样的多维数组,
y=[0;1]
我需要制作一个完全相似的数组,但仅包含每个年龄段(1,2和3)的最低价格值,对于2岁年龄段,将会有更多的价格(每个0-2和3-12岁)例如)基于不同的年龄范围(ageFrom和ageTo)。
其余的数组结构将保持不变。
输出数组将是这样,
[0] => Array ( [contractId] => 1 [pricingDetails] => Array (
[0] => Array ( [pricingName] => Price1 [priceId] => 1 [ageGroup] => 1 [ageFrom] => 13 [ageTo] => 50 [price] => 110.00 )
[1] => Array ( [pricingName] => Price2 [priceId] => 2 [ageGroup] => 1 [ageFrom] => 13 [ageTo] => 50 [price] => 77.00 )
[2] => Array ( [pricingName] => Price3 [priceId] => 3 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 30.00 )
[3] => Array ( [pricingName] => Price4 [priceId] => 4 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 30.00 )
[4] => Array ( [pricingName] => Price5 [priceId] => 5 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 11.00 )
[5] => Array ( [pricingName] => Price6 [priceId] => 6 [ageGroup] => 2 [ageFrom] => 0 [ageTo] => 2 [price] => 0.00 )
[6] => Array ( [pricingName] => Price7 [priceId] => 7 [ageGroup] => 3 [ageFrom] => 51 [ageTo] => 149 [price] => 40.00 )
[7] => Array ( [pricingName] => Price8 [priceId] => 8 [ageGroup] => 3 [ageFrom] => 51 [ageTo] => 149 [price] => 30.00 )
[8] => Array ( [pricingName] => Price9 [priceId] => 9 [ageGroup] => 3 [ageFrom] => 51 [ageTo] => 149 [price] => 80.00 ) )
[1] => Array ( [contractId] => 2 [pricingDetails] => Array (
[0] => Array ( [pricingName] => Price1 [priceId] => 10 [ageGroup] => 1 [ageFrom] => 13 [ageTo] => 50 [price] => 120.00 )
[1] => Array ( [pricingName] => Price2 [priceId] => 11 [ageGroup] => 1 [ageFrom] => 13 [ageTo] => 50 [price] => 80.00 )
[2] => Array ( [pricingName] => Price3 [priceId] => 12 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 35.00 )
[3] => Array ( [pricingName] => Price4 [priceId] => 13 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 35.00 )
[4] => Array ( [pricingName] => Price5 [priceId] => 14 [ageGroup] => 2 [ageFrom] => 3 [ageTo] => 12 [price] => 15.00 )
[5] => Array ( [pricingName] => Price6 [priceId] => 15 [ageGroup] => 2 [ageFrom] => 0 [ageTo] => 2 [price] => 0.00 )
[6] => Array ( [pricingName] => Price7 [priceId] => 16 [ageGroup] => 3 [ageFrom] => 51 [ageTo] => 149 [price] => 45.00 )
[7] => Array ( [pricingName] => Price8 [priceId] => 17 [ageGroup] => 3 [ageFrom] => 51 [ageTo] => 149 [price] => 35.00 )
) ) ))
答案 0 :(得分:0)
此OP的历史记录是不接受任何答案,但我还是会回答。我要做的是创建一个分组名称,以便我可以选择价格最低的年龄段。
我将为此创建一个临时容器。将它们分组后,在批次的末尾。我将其展平,然后用新分组的数组覆盖该数组。
这是我的主意:
then
这是一个示例fiddle
让我知道是否还有另一种方法。