你能告诉我为什么要给我很多通知吗?
我是 php 新手,不明白我的错误在哪里,请注意:
<td>'.$columns[1].'</td>
到线:
$sum+=$columns[2];
这是我的代码:
<?php
if(file_exists('data.txt'))
{
$result= file('data.txt');
$sum='0';
foreach($result as $value)
{
$columns=explode('-', $value);
echo '<tr>
<td>'.$columns[0].'</td>
<td>'.$columns[1].'</td>
<td>'.$columns[2].'</td>
<td>'.$kinds[trim($columns[3])].'</td>
</tr>';
$sum+=$columns[2];
}
echo '<tr>
<td>--</td>
<td>--</td>
<td>' . $sum . ' </td>
<td>--</td>
</tr>';
}
?>
我是 php 新手,不明白我的错误在哪里 :( 来自行的通知
<td>'.$columns[1].'</td>
到线
$sum+=$columns[2];
以下是注意事项:
Notice: Undefined offset: 3 in C:\xampp\htdocs\HomeworkOne\index.php on line 31
Notice: Undefined index: in C:\xampp\htdocs\HomeworkOne\index.php on line 31
Notice: Undefined offset: 2 in C:\xampp\htdocs\HomeworkOne\index.php on line 33
Notice: Undefined offset: 1 in C:\xampp\htdocs\HomeworkOne\index.php on line 29
Notice: Undefined offset: 2 in C:\xampp\htdocs\HomeworkOne\index.php on line 30
Notice: Undefined offset: 3 in C:\xampp\htdocs\HomeworkOne\index.php on line 31
Notice: Undefined index: in C:\xampp\htdocs\HomeworkOne\index.php on line 31