4
When the user of a submit
in the form, I receive the following arrays (in this case I had 3 products in the form, if I had only 1, in the 4 arrays I would have only the Indice 0, if I had 5 products, in the 4 arrays I would have indices 0, 1, 2, 3 and 4)
'tempero' =>
array (size=3)
0 => string 'Ketchup' (length=7)
1 => string 'Mustard' (length=7)
2 => string 'Barbecue' (length=8)
'quantidade' =>
array (size=3)
0 => string '1' (length=1)
1 => string '2' (length=1)
2 => string '3' (length=1)
'frequencia' =>
array (size=3)
0 => string 'FKetchup' (length=2)
1 => string 'FMustard' (length=2)
2 => string 'FBarbecue' (length=2)
'combo' =>
array (size=3)
0 => string 'CKetchup' (length=2)
1 => string 'CMustard' (length=2)
2 => string 'CBarbecue' (length=2)
My problem is this, I would need to join the corresponding items in arrays, in case, I would need something like this:
'tempero1' =>
array (size=3)
0 => string 'Ketchup' (length=7)
1 => string '1' (length=7)
2 => string 'FKetchup' (length=8)
3 => string 'CKetchup' (length=8)
'tempero2' =>
array (size=3)
0 => string 'Mustard' (length=7)
1 => string '2' (length=7)
2 => string 'FMustard' (length=8)
3 => string 'CMustard' (length=8)
'tempero3' =>
array (size=3)
0 => string 'Barbecue' (length=7)
1 => string '3' (length=7)
2 => string 'FBarbecue' (length=8)
3 => string 'CBarbecue' (length=8)
How could I do to join the corresponding items into a single array, perhaps using a foreach?
Ball show, that’s exactly what I was looking for. I had tried with various forms of
foreach
, but in the end you didn’t have to use.– D. Watson