I have a multidimensionel array of different departments, and a want to loop through it using a foreach loop, but for some reason, the foreach loop grabs the values under the first key through every iteration.
The array looks like this:
$departmentArray = Array ( [0] => Array ( [dpt_id] => 5 [dpt_name] => Administration [dpt_employees] => Array ( [0] => Array ( [started] => 2000-06-01 [stopped] => 9999-99-99 [empl_id] => 21 ) [1] => Array ( [started] => 2000-06-01 [stopped] => 2010-01-01 [empl_id] => 23 ) ) ) [1] => Array ( [dpt_id] => 6 [dpt_name] => Warehouse [dpt_employees] => Array ( [0] => Array ( [started] => 2000-10-01 [stopped] => 2012-01-01 [empl_id] => 30 ) [1] => Array ( [started] => 2007-10-17 [stopped] => 9999-99-99 [empl_id] => 197 ) ) ) ) And the foreach loop looks like this:
foreach($departmentArray as $key => $value) { print_r($key); print_r($value['dpt_name']); } And this prints:
0 Administration 1 Administration. Does anyone know, why the loop does not move forward in the array and grab the value (Warehouse) under key/index 1 during its second iteration?