I have a form on my page. On “submit” I need to get the post data from the form and store it in a multidimensional array.
This is what I have so far.
//view
<input type="text" name="option[fname]" />
<input type="text" name="option[lname]" />
<input type="submit" />
//controller
$data['myarray'] = $this->input->post('options', TRUE);
$this->load->view('template',$data);
Then on “submit” we go back to the view and see what we have added.
//view
<?php
foreach($myarray as $row){
echo $myarray['fname'] . '<br>' . $myarray['lname'];
}
?>
I want to be able to keep adding to the array each time I hit “submit”. Right now it is only displaying the last entered data. How do I do that? Thanks?
You must save your array in a file, a cookie or a database at each request.
Simplified example with saving to file: