Can u tell me why show me tons of notice ?
I am new in php and don't understand where is my mistake, notices from line:
<td>'.$columns[1].'</td>
To line:
$sum+=$columns[2];
Here is my code:
<?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>';
}
?>
I am new in php and don't understand where is my mistake :( notices from line
<td>'.$columns[1].'</td>
to line
$sum+=$columns[2];
Here are the notices:
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