Undefined offset when writing to a file
<p>I am attempting to write to a file using PHP. I am writing data from arrays. </p>

<p>Here's my code: </p>

<pre><code>    $subject = $_SESSION['subject'];
    $section = $_SESSION['section'];
    $exam1 = $_SESSION['exam1'];
    $exam2 = $_SESSION['exam2'];
    $finalexam = $_SESSION['finalexam'];
    $average = $_SESSION['average'];

    $studentArray = $_SESSION['stringArray'];

    $file = $subject . "-" . $section . ".txt";
    $fh = fopen($file, 'a');
    $size = sizeof($studentArray);
    for($i = 0; $i&lt;$size; $i++){
        fwrite($fh, $studentArray[$i] . " " . $exam1[$i] . " " . $exam2[$i] . " " .       $finalexam[$i] . " " . $average[$i] . " ");
}
</code></pre>

<p>I always get this notice when I try to access this page:</p>

<pre><code> Notice: Undefined offset: 5 in C:\xampp\htdocs\CS120\MP\Grades.php on line 26
</code></pre>

<p>Line 26 is the one with the fwrite in the for-loop.
There's always a notice but the code writes to the file correctly.
Is there anything that can be done to remove/solve the notice/error?</p>
