Como agrupar chaves e valores idênticos de um array?
Podem existir N arrays dentro do array, não pode adicionar chaves iguais.
Por exemplo:
[attributes] => Array
(
[0] => Array
(
[title] => Cor
[type] => text
[values] => Array
(
[1] => Amarelo
)
)
[1] => Array
(
[title] => Cor
[type] => text
[values] => Array
(
[2] => Azul
)
)
[2] => Array
(
[title] => Largura
[type] => text
[values] => Array
(
[2] => Grande
)
)
Resultado desejado:
[attributes] => Array
(
[0] => Array
(
[title] => Cor
[type] => text
[values] => Array
(
[1] => Amarelo
[2] => Azul
)
)
[2] => Array
(
[title] => Largura
[type] => text
[values] => Array
(
[2] => Grande
)
)
title
etype
forem iguais, cor e largura são exemplos, mas pode vir qualquer valor, quando iguais, agrupar osvalues
.array
, que compare otitle
com os já existentes e se houver um igual acrescenta aovalues