CodeIgniter Forums
Handle $_POST[ ][ ] arrays - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Handle $_POST[ ][ ] arrays (/thread-29537.html)



Handle $_POST[ ][ ] arrays - El Forum - 04-13-2010

[eluser]Unknown[/eluser]
Hi there,

I know this has been discussed earlier.
Even though this code is working, I´m sure that this is not the best solution - am I right?

Controller:
Code:
$count = 3
    function save()
    {
        for ($i=0; $i < $count; $i++)
        {
            $persons = array
            (
                'Firstname'  => $_POST['Firstname'][$i],
                'Lastname'   => $_POST['Lastname'][$i],
                'Gender'     => $_POST['Gender'][$i]
            );
            $this->personModel->save($persons);
        }
    }

Thanks.