过滤二维数组以仅保留其他重复行中具有最高值的唯一行
我有一个如下所示的数组:
$array[1]['first__name'] = 'john';
$array[1]['last_name'] = 'anderson';
$array[1]['sum'] = 100;
$array[2]['first__name'] = 'john';
$array[2]['last_name'] = 'anderson';
$array[2]['sum'] = 200;
$array[3]['first__name'] = 'julie';
$array[3]['last_name'] = 'Scott';
$array[3]['sum'] = 300;
$array[4]['first__name'] = 'Eva';
$array[4]['last_name'] = 'Scott';
$array[4]['sum'] = 300;
$array[5]['first__name'] = 'john';
$array[5]['last_name'] = 'anderson';
$array[5]['sum'] = 300;
我想比较 sum 的值,其中 first_name = john
、last_name = anderson
并保存最高的值。其余的我想删除。
I have an array that looks like this:
$array[1]['first__name'] = 'john';
$array[1]['last_name'] = 'anderson';
$array[1]['sum'] = 100;
$array[2]['first__name'] = 'john';
$array[2]['last_name'] = 'anderson';
$array[2]['sum'] = 200;
$array[3]['first__name'] = 'julie';
$array[3]['last_name'] = 'Scott';
$array[3]['sum'] = 300;
$array[4]['first__name'] = 'Eva';
$array[4]['last_name'] = 'Scott';
$array[4]['sum'] = 300;
$array[5]['first__name'] = 'john';
$array[5]['last_name'] = 'anderson';
$array[5]['sum'] = 300;
I want to compare the values of sum where first_name = john
, last_name = anderson
and save the highest. The rest I would like to remove.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个怎么样?
How about this?
这也将起作用:)
This will also work :)