string(3) "298" ["user_id"] => string(1) "1" ["due_in"] => string(15) "8.33" } [1] => array(6) { ["pla_id"] =>"/> string(3) "298" ["user_id"] => string(1) "1" ["due_in"] => string(15) "8.33" } [1] => array(6) { ["pla_id"] =>">

首页 >后端开发 >php教程 >php-PHP 数组中如果有一个元素相同,拼接其他元素

php-PHP 数组中如果有一个元素相同,拼接其他元素

WBOY
WBOY原创
2016-06-02 11:32:051231浏览

php

比如原数组是这样的
array(3) {
[0] => array(6) {
["pla_id"] => string(3) "298"
["user_id"] => string(1) "1"
["due_in"] => string(15) "8.33"
}
[1] => array(6) {
["pla_id"] => string(3) "976"
["user_id"] => string(1) "1"
["due_in"] => string(15) "338.90"
}
[2] => array(6) {
["pla_id"] => string(3) "56"
["user_id"] => string(1) "2"
["due_in"] => string(15) "25.6"
}}

因为数组中的user_id=1 是一样的
要得到最后这样数组,要怎么写(就是把user_id相同的其他元素拼接在一起)?
array(3) {
[0] => array(6) {
["pla_id"] => string(3) "298,976"
["user_id"] => string(1) "1"
["due_in"] => string(15) "8.33,338.90"
}

[1] => array(6) {
["pla_id"] => string(3) "56"
["user_id"] => string(1) "2"
["due_in"] => string(15) "25.6"
}}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn