php数组合并处理
发布网友
发布时间:2023-11-03 20:45
我来回答
共3个回答
热心网友
时间:2024-12-12 14:15
$arr_1 = array(
'4 - 22 - downlogs' => 4,
'4 - 23 - downlogs' => 3,
'4 - 24 - downlogs' => 3,
'4 - 25 - downlogs' => 3,
);
$arr_2 = array(
'4 - 22 - downlogs' => 1,
'4 - 23 - downlogs' => 3,
'4 - 24 - downlogs' => 3,
'4 - 25 - downlogs' => 3,
);
$arr = array_merge_recursive($arr_1, $arr_2);
$new_arr = array();
foreach ($arr as $k => $v) {
$new_arr[] = $k . '-' . implode("-", $v);
}
var_mp($new_arr);
热心网友
时间:2024-12-12 14:16
$arr1 = array(
'4 - 22 - downlogs' => 4,
'4 - 23 - downlogs' => 3,
'4 - 26 - downlogs' => 3,
'4 - 22 - viewlogs' => 6,
'4 - 23 - viewlogs' => 3,
'4 - 26 - viewlogs' => 4,
);
$arr2 = array(
'4 - 22 - downlogs' => 1,
'4 - 23 - downlogs' => 1,
'4 - 26 - downlogs' => 2,
'4 - 22 - viewlogs' => 2,
'4 - 23 - viewlogs' => 1,
'4 - 26 - viewlogs' => 2,
);
$new = array();
foreach ($arr1 AS $key => $value)
{
$new[] = $key . ' - ' . $value . ' - ' . $arr2[$key];
}
var_mp($new);
热心网友
时间:2024-12-12 14:16
先把 两个数组的值组合好 再用 foreach(sss as key =>value)的 键值都能独取出来 然后你再单独入push数组