I have an array and I am trying to loop over it with foreach but I am getting the
Invalid argument supplied for foreach() on the inner loop.
I am not sure what I have incorrect. I have tried with using $key
Here is the array:
array(3) { ["company_id"]=> string(3) "159"
[0]=> array(9) {
["company_id"]=> string(3) "159"
["employee_id"]=> string(3) "544"
["pay_week1"]=> string(1) "0" }
[1]=> array(9) {
["company_id"]=> string(3) "159"
["employee_id"]=> string(3) "545" } }
My loop:
foreach ($this->request->data['MonthlyReturn'] as $key=>$m) // Cycle through each record
{
foreach ($key as $empl)
{
$employee = $empl['employee_id'];
print '<pre>';
print_r ($employee);
exit;
}