I have an array mentioned below.
$array = array(
'0' => array(
'names' => array(0 => 'Apple'),
'group' => 1
),
'1' => array(
'names' => array(0 => 'Mango'),
'group' => 1
),
'2' => array(
'names' => array(0 => 'Grapes'),
'group' => 1
),
'3' => array(
'names' => array(0 => 'Tomato'),
'group' => 2
),
'4' => array(
'names' => array(0 => 'Potato'),
'group' => 2
)
);
I want the result in such a way that the if the value of the array key "group" is same then the values of the key "names" should be merged. I want the output mentioned below.
$array = array(
'0' => array(
'names' => array(0 => 'Apple', 1 => 'Mango', 2 => 'Grapes'),
'group' => 1
),
'1' => array(
'names' => array(0 => 'Tomato', 1 => 'Potato'),
'group' => 2
)
);