string(3) "298"["user_id"] => string(1) "1"["">
时间:2021-07-01 10:21:17 帮助过:3人阅读
$a = array(
array(
"pla_id" => "298",
"user_id" => "1",
"due_in" => "8.33",
),
array(
"pla_id" => "976",
"user_id" => "1",
"due_in" => "338.90",
),
array(
"pla_id" => "56",
"user_id" => "2",
"due_in" => "25.6",
)
);
$b = array();
foreach($a as $v) {
if(! isset($b[$v['user_id']])) $b[$v['user_id']] = $v;
else $b[$v['user_id']]["due_in"] .= ',' . $v["due_in"];
}
var_dump(array_values($b));
array(2) {
[0]=> array(3) {
["pla_id"]=> string(3) "298"
["user_id"]=> string(1) "1"
["due_in"]=> string(11) "8.33,338.90"
}
[1]=> array(3) {
["pla_id"]=> string(2) "56"
["user_id"]=> string(1) "2"
["due_in"]=> string(4) "25.6"
}
}