I have one form which has two text fields. One is Price and another one is share.These text fields are repeating for every row. I am extracting the values after submit in a post array. But the POST array coming in a normal way. I want it in a specific way like below.
<td colspan="3"><label><?php echo form_error('amount'); ?></label><input type="text" class="textsmall" name="post_cost[]" id="<?php echo $cust_id_cur; ?>" value="<?php echo set_value('amount'); ?>" /></td>
<td colspan="3"><label><?php echo form_error('share'); ?></label><input type="text" class="textsmall" name="post_share[]" id="<?php echo $cust_id_cur; ?>" value="100" /></td>
These are the two text fields. When i submit the POST array is like this……..
post_cost
(
[0] => 324123
[1] => 324123
[2] => 324123
[3] => 324123
[4] => 324123
[5] => 324123
)
post_share
(
[0] => 100
[1] => 100
[2] => 100
[3] => 100
[4] => 100
[5] => 100
)
But i want two of the above arrays like this. There is filed called $cust_id_cur that is unique filed. I want values of each array against those id’s. What i mean is there six rows totally so there will be six cust_id's.
post_cost
(
[$cust_id_cur] => 324123
[$cust_id_cur] => 324123
[$cust_id_cur] => 324123
[$cust_id_cur] => 324123
[$cust_id_cur] => 324123
[$cust_id_cur] => 324123
)
why i am asking like this is my order of cust_id's are not always same. So i will give against cust_id. When i submit i need to save them in the database against that cust_id. So i want array like the above.
You can populate the index with your variable in the loop: