21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$arr = array(
18 => array(
'date' => '2020-02-29 09:52:52',
'title' => '10692450361900',
'content' => '【腾讯云】尊敬的用户,自2020年3月2日起,腾讯云将对国际/港澳台短信内容长度计算规则进行调整,详情请查看:https://url.'
),
19 => array(
'date' => '2020-02-29 09:52:52',
'title' => '10692450361900',
'content' => 'cn/5R4Ghvq 。'
),
20 => array(
'date' => '2020-03-29 09:52:52',
'title' => '10692450361900',
'content' => '【信息2】'
),
21 => array(
'date' => '2020-03-29 09:52:52',
'title' => '10692450361900',
'content' => '测试合并 。'
)
);
$result = array();
foreach($arr as $k => $v) {
$next = next($arr);
if($next['date'] == $v['date'] && $next['title'] == $v['title']) {
$v['content'] .= $next['content'];
$key = array_search($next, $arr);
//unset($arr[array_search($next, $arr)]);
} else if($k == $key) {
continue;
}
$result[] = $v;
}
//输出处理结果
var_dump($result);