У меня есть следующая структура массива, и я успешно перебираю часть [LoyaltyHistory], используя для каждого цикла:
Array
(
[0] => Array
(
[LoyaltyHistory] => Array
(
[id] => 5
[user_id] => 32
[points] => 4
[date] => 2012-02-07
[total] => 146
)
[User] => Array
(
)
)
[1] => Array
(
[LoyaltyHistory] => Array
(
[id] => 6
[user_id] => 32
[points] => -6
[date] => 2012-02-07
[total] => 140
)
[User] => Array
(
)
)
[2] => Array
(
[LoyaltyHistory] => Array
(
[id] => 7
[user_id] => 32
[points] => -5
[date] => 2012-02-07
[total] => 135
)
[User] => Array
(
)
)
[3] => Array
(
[LoyaltyHistory] => Array
(
[id] => 8
[user_id] => 32
[points] => 15
[date] => 2012-02-07
[total] => 150
)
[User] => Array
(
)
)
[4] => Array
(
[LoyaltyHistory] => Array
(
[id] => 9
[user_id] => 32
[points] => 5
[date] => 2012-02-10
[total] => 155
)
[User] => Array
(
)
)
[5] => Array
(
[LoyaltyHistory] => Array
(
[id] => 10
[user_id] => 32
[points] => 155
[date] => 2012-03-04
[total] => 305
)
[User] => Array
(
)
)
[6] => Array
(
[LoyaltyHistory] => Array
(
[id] => 11
[user_id] => 32
[points] => -5
[date] => 2012-03-04
[total] => 300
)
[User] => Array
(
)
)
[7] => Array
(
[LoyaltyHistory] => Array
(
[id] => 12
[user_id] => 32
[points] => 5
[date] => 2012-03-05
[total] => 305
)
[User] => Array
(
)
)
)
структура для каждого цикла структурирована следующим образом:
<?php foreach ($history as $hist)
{
if($hist['LoyaltyHistory']['points'] > 0) $hist['LoyaltyHistory']['points'] = '+'.$hist['LoyaltyHistory']['points'];?>
<tr>
<td><?php echo $hist['LoyaltyHistory']['date']; ?></td>
<td><?php echo $hist['LoyaltyHistory']['points']; ?></td>
<td><?php echo $hist['LoyaltyHistory']['total']; ?></td>
</tr>
<?php } ?>
Для каждого цикла выводятся правильные элементы из массива, но при этом выдается следующее предупреждение: 'Warning (2): Invalid argument supplied for foreach()'
, и я не могу понять, почему.