【发布时间】:2015-05-15 19:10:47
【问题描述】:
我在第二次迭代时遇到了问题,看看下面的代码:
include ('rest.php');
include ('header.php');
include ('topo.php');
include ('menu.php');
$token = $_COOKIE['token'];
$table1 = "<div class='pai-forms'>
<table id='calendarTable'>
<tr>
<th>Posição Array</th>
<th>Nome</th>
<th>Email</th>
<th>CEP</th>
<th>Numero</th>
<th>Complemento</th>
<th>Rua</th>
<th>Logo</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Ativo</th>
<th>Criado</th>
<th>Atualizado</th>
</tr>";
$table2 = " </table>
</div>";
$dataSalons = wsListSalons($token);
echo $table1;
foreach ($dataSalons['data'] as $key => $value) {
echo "<tr>";
for ($i = 1; $i < 6; $i++) { // HERE IS THE PROBLEM
echo "<td>".$value[$key]."</td>";
}
echo "</tr>";
}
echo $table2;
include ('footer.php');
我只想获取数组索引1到6的数据,但是当for ($i = 1; $i < 6; $i++)这一行执行时,它会抛出许多这样的错误:
注意:未定义的偏移量:C:\xampp\htdocs\mcisalaositeadmin\list_salons.php 第 39 行中的 0
注意:未定义的偏移量:C:\xampp\htdocs\mcisalaositeadmin\list_salons.php 第 39 行中的 0
注意:未定义的偏移量:第 39 行 C:\xampp\htdocs\mcisalaositeadmin\list_salons.php 中的 1
注意:未定义的偏移量:C:\xampp\htdocs\mcisalaositeadmin\list_salons.php 第 39 行中的 1
我错过了什么?
PS:我刚刚尝试了一个 foreach 循环,它可以工作,但它会将所有索引数据返回给我。我只想获取索引数据 1 到 6。
【问题讨论】: