tp5 遍历二维数组,保留相同的键值,不同的键值拼接放在一起

浏览:92 发布日期:2019/10/28 分类:ThinkPHP5专区 关键字: tp5 遍历二维数组 合并二维数组 相同的键值

$arr = [
[
"id"=> '1',
"period_id"=> "100",
"police_id"=> 'a01',
"account_name"=> "李四",
"period"=> "测试内容一"
],
[
"id"=> '2',
"period_id"=> '200',
"police_id"=> 'a01',
"account_name"=> "李四",
"period"=> "测试内容二"
],
[
"id"=> '3',
"period_id"=> '300',
"police_id"=> 'a02',
"account_name"=> "张三",
"period"=> "测试内容三"
]
];

$arr = [
[
"id"=> '1、2',
"period_id"=> "100、200",
"police_id"=> 'a01',
"account_name"=> "李四",
"period"=> "测试内容一、测试内容二"
],
[
"id"=> '3',
"period_id"=> '300',
"police_id"=> 'a02',
"account_name"=> "张三",
"period"=> "测试内容三"
]
];
如图所示,如何将原始的二维数组,合并变成想要的二维数组,向各位大佬请教
最佳答案
评论( 相关
后面还有条评论,点击查看>>