6
I have a grid form that returns the following values within 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’d like to know is if there’s any function to unite the values of pei_quantidade
where the values of prg_cod_barra
are the same.
In this 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)
There is such a function?
If the data is coming repeated it is easier to give a
GROUP BY
at the time of query mysql– Silvio Andorinha
But this data does not come from Mysql, are informed in the form
– Lucas Padilha
could not use prg_cod_barra as the main key?
– Daniel Omine