I have a grid-shaped form that returns the following values inside an Array:
array (size=3)
0 =>
array (size=5)
'pei_seq' => int 0
'prg_cod_barra' => string '7899619704729' (length=13)
'pei_prg_cod' => string '483' (length=3)
'pei_valor' => string '42.00' (length=5)
'pei_quantidade' => string '1' (length=1)
1 =>
array (size=5)
'pei_seq' => int 1
'prg_cod_barra' => string '7899619704729' (length=13)
'pei_prg_cod' => string '483' (length=3)
'pei_valor' => string '42.00' (length=5)
'pei_quantidade' => string '1' (length=1)
2 =>
array (size=5)
'pei_seq' => int 2
'prg_cod_barra' => string '7899619704705' (length=13)
'pei_prg_cod' => string '481' (length=3)
'pei_valor' => string '31.00' (length=5)
'pei_quantidade' => string '1' (length=1)
What I would like to know is if there is any function to join the values of pei_quantidade
whenever the values of prg_cod_barra
are equal.
In case, I wanted the array to return:
array (size=2)
0 =>
array (size=5)
'pei_seq' => int 0
'prg_cod_barra' => string '7899619704729' (length=13)
'pei_prg_cod' => string '483' (length=3)
'pei_valor' => string '42.00' (length=5)
'pei_quantidade' => string '2' (length=1)
1 =>
array (size=5)
'pei_seq' => int 2
'prg_cod_barra' => string '7899619704705' (length=13)
'pei_prg_cod' => string '481' (length=3)
'pei_valor' => string '31.00' (length=5)
'pei_quantidade' => string '1' (length=1)
Is there such a function?