I have two arrays:
$item dates basicaly looks like this:
Array (
[0] => 2012-05-28
[1] => 2012-05-29
[2] => 2012-05-30
[3] => 2012-05-31
[4] => 2012-06-01
)
and $m['details'] looks like this:
Array (
[details] => Array (
[0] => Array (
[Id] => 20003
[MTimeInt] => 0
[Date] => 2012-05-28
[Name] => item
)
[1] => Array (
[Id] => 20004
[MTimeInt] => 1
[Date] => 2012-05-29
[Name] => item2
)
[2] => Array (
[Id] => 20005
[MealTimeInt] => 0
[Date] => 2012-05-29
[Name] => item3
)
)
)
//start of main bit
<?php foreach($m['details'] as $item) { ?>
<?php if($item['MTimeInt'] == 0 && $item['Date'] == $itemDates[0]) { ?>
<?php echo $item['Name']; ?> <br>
<?php } ?>
<?php if($item['MTimeInt'] == 0 && $item['Date'] == $itemDates[1]) { ?>
<?php echo $item['Name']; ?>
<?php } ?>
<?php } ?>
The problem I am having the foreach loop breaks after it has iterated once. When after the if statement has been fulfilled it should continue looping (by moving onto the next index/item onto the list) until all of the items have been checked.
I previously used a while loop without much success.
Any idea why this is happening?
Thanks
The
$m['details']have only one element, look closer.Maybe want you iterate over
$m['details']['details']?