Cakephp 1.3 铁路超高设置::从数据结构提取()
我有一个类似下面的数据结构(只是更大,这是一个片段)。我试图生成以美元格式提供的所有Cakephp 1.3 铁路超高设置::从数据结构提取(),cakephp-1.3,Cakephp 1.3,我有一个类似下面的数据结构(只是更大,这是一个片段)。我试图生成以美元格式提供的所有technologyinctiveamount值的总和Set::extract似乎是一种快速、轻松地完成这项工作的自然方式,但如果我能让它完成我认为应该做的事情,我会被诅咒的。我知道Set::extract只支持XPath子集,但我想我是在这个上下文中工作的。我试过了 Set::extract( '/' . $group . '/IncentiveAmountType[incentive_amount_type_
technologyinctive
amount值的总和Set::extract
似乎是一种快速、轻松地完成这项工作的自然方式,但如果我能让它完成我认为应该做的事情,我会被诅咒的。我知道Set::extract
只支持XPath子集,但我想我是在这个上下文中工作的。我试过了
Set::extract( '/' . $group . '/IncentiveAmountType[incentive_amount_type_id=USD]/../TechnologyIncentive/amount', $incentives )
Set::extract( '/' . $group . '/{n}/IncentiveAmountType[incentive_amount_type_id=USD]/../TechnologyIncentive/amount', $incentives )
$group
值在下面的结构中计算为“Appliances”或“Building Shell”。其他组存在于数据结构的非简略版本中。我可以理解它被“建筑外壳”中的空间弄糊涂了,但它甚至不适用于“电器”。我希望我只是有点不对劲,我看不见东西了
其思想是获取一个值数组,然后对其抛出array\u sum()
,以获取每组的总值
谢谢你的帮助。我正在研究的数据结构如下
Array
(
[Appliances] => Array
(
[875] => Array
(
[TechnologyIncentive] => Array
(
[id] => 875
[incentive_id] => ccf4ceb8-6538-11e0-9cbb-00259028905a
[technology_id] => d4da5c6a-6538-11e0-9cbb-00259028905a
[amount] => 75.00
[incentive_amount_type_id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[is_active] => 1
)
[IncentiveAmountType] => Array
(
[id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[incentive_amount_type_id] => USD
[name] => $
[description] => US Dollars
[version] => 0
[display] => 1
)
)
[1103] => Array
(
[TechnologyIncentive] => Array
(
[id] => 1103
[incentive_id] => ccf4c9b8-6538-11e0-9cbb-00259028905a
[technology_id] => d4da5c6a-6538-11e0-9cbb-00259028905a
[amount] => 50.00
[incentive_amount_type_id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[is_active] => 1
)
[IncentiveAmountType] => Array
(
[id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[incentive_amount_type_id] => USD
[name] => $
[description] => US Dollars
[version] => 0
[display] => 1
)
)
)
[Building Shell] => Array
(
[1110] => Array
(
[TechnologyIncentive] => Array
(
[id] => 1110
[incentive_id] => ccf4c9b8-6538-11e0-9cbb-00259028905a
[technology_id] => d4d9b79c-6538-11e0-9cbb-00259028905a
[amount] => 150.00
[incentive_amount_type_id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[is_active] => 1
)
[IncentiveAmountType] => Array
(
[id] => 0fb78496-6ad6-11e0-9cbb-00259028905a
[incentive_amount_type_id] => USD
[name] => $
[description] => US Dollars
[version] => 0
[display] => 1
)
)
[10941] => Array
(
[TechnologyIncentive] => Array
(
[id] => 10941
[incentive_id] => ccf4ceb8-6538-11e0-9cbb-00259028905a
[technology_id] => d4d9b79c-6538-11e0-9cbb-00259028905a
[amount] => 40.00
[incentive_amount_type_id] => 0fb783c4-6ad6-11e0-9cbb-00259028905a
[is_active] => 1
)
[IncentiveAmountType] => Array
(
[id] => 0fb783c4-6ad6-11e0-9cbb-00259028905a
[incentive_amount_type_id] => PERC
[name] => %
[description] => Percent
[version] => 0
[display] => 1
)
)
)
)