$rows = getChallengeList();
error_log(print_r($rows, 1));
?>
<table border="1">
<tr><th>ID</th><th>Title</th><th>Description</th></tr>
<?php foreach ($rows as $row): ?>
<?php foreach($row as $chal): ?>
<tr>
<td><?= $chal['loyalty_challenges_id']; ?></td>
<td><?= $chal['title']; ?></td>
<td><?= $chal['description']; ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
error_log 返回:
[11-Jan-2013 10:44:27] Array
(
[0] => Array
(
[loyalty_challenges_id] => 1
[title] => New Customer Special
[description] => Reward new customers with a free order of breadsticks after placing their second order during their first 30 days
)
[1] => Array
(
[loyalty_challenges_id] => 2
[title] => Frequent Flyer Special
[description] => Reward long-time customers who order often with a free pizza
)
)
但循环呈现的值如下所示:
<table border="1">
<tr><th>ID</th><th>Title</th><th>Description</th></tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>N</td>
<td>N</td>
<td>N</td>
</tr>
<tr>
<td>R</td>
<td>R</td>
<td>R</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>F</td>
<td>F</td>
<td>F</td>
</tr>
<tr>
<td>R</td>
<td>R</td>
<td>R</td>
</tr>
</table>
知道什么会导致这种情况吗?自从我使用直接 php 而不是拥有自己的数组处理功能的 CMS 以来,已经有一段时间了。