6
with a doubt in performing a foreach and incrementing another helper to perform an Insert in the bank, see only:
When I send a form via post I have the following array as a result:
array (size=2)
'quantidade' =>
array (size=8)
0 => string '10' (length=2)
1 => string '11' (length=2)
2 => string '15' (length=0)
3 => string '22' (length=0)
4 => string '10' (length=0)
5 => string '9' (length=0)
6 => string '0' (length=0)
7 => string '35' (length=0)
'produto' =>
array (size=8)
0 => string '11' (length=1)
1 => string '18' (length=1)
2 => string '19' (length=1)
3 => string '21' (length=1)
4 => string '22' (length=2)
5 => string '25' (length=2)
6 => string '29' (length=2)
7 => string '22' (length=2)
How I’m using Codeigniter to get the Form data, using the following structure:
foreach ($this->input->post() as $chave => $valor) {
//o array aux aqui
}
Any idea how to generate this result by taking the first value of each element and inserting it into an auxiliary array:
Kind of:
$array_aux[0] = array('quantidade' => 10, 'produto' => 11)
...
$array_aux[7] = array('quantidade' => 35, 'produto' => 22)
Wouldn’t it be better to make one normal and 'control' the two indices by
$i
?– rray
Hello @rray, so I’m using codeigniter and picking up these variables through $this->input->post(), so I thought about foreach. You could help me use the for that?
– tkmtts
This auxiliary array you will send to the bank? what is its structure?
– rray
yes, I will send it to the bank. The DB structure is id, quantity. That in the example I passed the id is equal to product key
– tkmtts