2
I have a huge multidimensional array and need to remove duplicate values with PHP or some function that does this when using Cakephp. Array structure:
Array
(
[0] => Array
(
[Advertencia] => Array
(
[id] =>
[tipo_punicao] => CA
[suspensao_data_inicio] =>
[funcionario_matricula] =>
[advertente_matricula] =>
[recebedor_RH_matricula] =>
)
[Funcionario] => Array
(
[id] => 25
[matricula] => 5444
[nome] => ANDRE
[quantidade] =>
)
)
[1] => Array
(
[Advertencia] => Array
(
[id] =>
[tipo_punicao] => A
[suspensao_data_inicio] =>
[funcionario_matricula] =>
[advertente_matricula] =>
[recebedor_RH_matricula] =>
)
[Funcionario] => Array
(
[id] => 20
[matricula] => 5555
[nome] => JOAO
[quantidade] =>
)
)
[2] => Array
(
[Advertencia] => Array
(
[id] =>
[tipo_punicao] => RC
[suspensao_data_inicio] =>
[funcionario_matricula] =>
[advertente_matricula] =>
[recebedor_RH_matricula] =>
)
[Funcionario] => Array
(
[id] => 20
[matricula] => 5555
[nome] => JOAO
[quantidade] =>
)
)
)
Note that two of these array data have the same information, ie [1]
and [2]
- where the nome
, matricula
and id
are equal. I would like one of these data to be removed. It does not matter which of the two will remain. It would look like this, for example:
Array
(
[0] => Array
(
[Advertencia] => Array
(
[id] =>
[tipo_punicao] => CA
[suspensao_data_inicio] =>
[funcionario_matricula] =>
[advertente_matricula] =>
[recebedor_RH_matricula] =>
)
[Funcionario] => Array
(
[id] => 25
[matricula] => 5444
[nome] => ANDRE
[quantidade] =>
)
)
[1] => Array
(
[Advertencia] => Array
(
[id] =>
[tipo_punicao] => A
[suspensao_data_inicio] =>
[funcionario_matricula] =>
[advertente_matricula] =>
[recebedor_RH_matricula] =>
)
[Funcionario] => Array
(
[id] => 20
[matricula] => 5555
[nome] => JOAO
[quantidade] =>
)
)
)
It is possible?
It looks like good code, I did exactly this and the returning array comes empty. ;(
– Rodrigo Segatto
It seems that your code works perfectly. I believe that in mine it did not work for some inconsistency of the array. Anyway I already found a way this array does not come by default with duplicate values. Thanks.
– Rodrigo Segatto