CodeIgniter Forums

Full Version: Handle $_POST[ ][ ] arrays
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.