当前位置:Gxlcms > PHP教程 > 数组加减有关问题

数组加减有关问题

时间:2021-07-01 10:21:17 帮助过:27人阅读

数组加减问题
已知数组a和b。

//数组a:
array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'part_count' => '32',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z25',
'part_count' => '32',
),
)

//数组b:

array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'total' => '48',
),
)


数组a cust_no为310F6 1VA5A时,对应的总量是32+32=64,数组b cust_no为310F6 1VA5A时对应的总量是48。
想求得数组b总量为48时,对应数组a中的哪些内容?数组a剩余的结果是多少?

以这个例子来说,
得到数组a的结果:

//数组a:
array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'part_count' => '32',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z25',
'part_count' => '16',
),
)

剩余数组a的结果:

//数组a:
array (
0 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2X15',
'part_count' => '0',
),
1 =>
array (
'cust_no' => '310F6 1VA5A',
'lotno' => '2Z25',
'part_count' => '16',
),
)


如何能得到这样的结果?

分享到:


------解决方案--------------------

人气教程排行