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

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Handle $_POST[ ][ ] arrays (/showthread.php?tid=29537)



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.