I'm sending a POST array to a controller. The array looks like such:
Array
(
[event] => Array
(
[0] => Array
(
['publishStart'] => 2013-12-10
['eventStart'] => 2014-05-05
['eventEnd'] => 2014-05-10
['timeStart'] =>
['timeEnd'] =>
['location_id'] => 1
['id'] => 65774
)
There are a few of these blocks, i.e. [event][1]. [event][2], etc. I'm attempting to run a foreach loop on $_POST['event'] and can confirm that on each iteration, $event contains the following:
Array
(
['publishStart'] => 2013-12-10
['eventStart'] => 2014-05-05
['eventEnd'] => 2014-05-10
['timeStart'] =>
['timeEnd'] =>
['location_id'] => 1
['id'] => 65774
)
Now, the problem. You can see in both above arrays there is a key called "id" with a corresponding value. Yet the following code returns a string of "undefined index" errors:
foreach ($_POST['event'] as $event)
{
echo $event['id'];
exit();
}
What on earth am I doing wrong?
event-block in your$_POST-array without anid-field.var_dump/print_rexactly in front of the loop?