For example, the original array is like this
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"
}}
Because the user_id=1 in the array is the same
To get the last such array, how do you write (that is, user_id the same other elements together)?
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"
}}
Reply to discussion (solution)
$a = Array ( "pla_id" = "298", "user_id" and "1", "due_in" and "8.33", ), Array ( "pla_id" = "976", "user_id" and "1", "due_in" and "338.90", ",", Array ( "pla_id" = > "user_id", "2", " due_in" and "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 (one) "8.33,338.90" } [1]=> Array (3) { ["Pla_ ID "]=> string (2)" ["user_id"]=> string (1) "2" ["due_in"]=> string (4) "25.6" }}
$a = Array ( "pla_id" = "298", "user_id" and "1", "due_in" and "8.33", ), Array ( "pla_id" = "976", "user_id" and "1", "due_in" and "338.90", ",", Array ( "pla_id" = > "user_id", "2", " due_in" and "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 (one) "8.33,338.90" } [1]=> Array (3) { ["Pla_ ID "]=> string (2)" ["user_id"]=> string (1) "2" ["due_in"]=> string (4) "25.6" }}
Thanks, thank you so much.