数组 a
Array
(
[0] => Array
(
[member_id] => 6
[sorting] => 0
[total] => 1
)
[1] => Array
(
[member_id] => 7
[sorting] => 1
[total] => 2
)
)
数组 b
Array
(
[0] => Array
(
[member_id] => 2
[total] => 3
)
[1] => Array
(
[member_id] => 6
[total] => 1
)
[2] => Array
(
[member_id] => 7
[total] => 2
)
)
问题:以上数据我尝试循环数组并存储到新数组中,如下所示(最终数据)。首先,如果第二个数组缺少成员数据,那么我需要从第一个数组中获取并将其存储到一个新数组中。除此之外,如果缺少排序,我需要从第一个数组中获取排序值。最后,我能够很好地获取所有数据,但最后一个值存储到其中会重复。任何人都可以对此提供帮助:(?我的逻辑停留在这里。
我的代码返回
Array
(
[0] => Array
(
[member_id] => 6
[total] => 1
[sorting] => 0
)
[1] => Array
(
[member_id] => 7
[total] => 2
[sorting] => 1
)
[2] => Array
(
[member_id] => 7
[total] => 2
[sorting] =>
)
)
最终数据应为:
Array
(
[0] => Array
(
[member_id] => 6
[total] => 1
[sorting] => 0
)
[1] => Array
(
[member_id] => 7
[total] => 2
[sorting] => 1
)
[2] => Array
(
[member_id] => 2
[total] => 3
[sorting] => 2
)
)