Notice: Undefined offset: 1, 2, 3 & 4
<p>I am trying to implement a simple search of a flat file. I am getting notices no matter what I try. I have tried adding <code>isset()</code> as well. The flat file consists of 5 fields:</p>

<pre><code>id, title, author, publisher, isbn
</code></pre>

<p>Results should show entire line except for the id of any found matches.  The results do show in the table for all of the matches for the four categories.
notices = </p>

<pre><code>Notice: Undefined offset: 1 in C:\PHP\search2.php on line 72
Notice: Undefined offset: 2 in C:\PHP\search2.php on line 72
Notice: Undefined offset: 3 in C:\PHP\search2.php on line 72
Notice: Undefined offset: 4 in C:\PHP\search2.php on line 72
</code></pre>

<p>This is what is on line 91: <code>$fields = strtolower($field[$loop][$cell]);</code>
I have tried to strip down the code to include only
relevant code:</p>

<pre><code>    &lt;?php
$find_this = $_POST['search'];
if ($find_this == '') {exit('You did not enter anything to search for!&lt;p&gt;&lt;a href="search.php"&gt;Search Again&lt;/a&gt;&lt;/p&gt;');}
?&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;link rel="stylesheet" href="style.css" type="text/css" /&gt;
&lt;title&gt;Search Details&lt;/title&gt;
&lt;style type="text/css"&gt;
table {
border:1px solid #000066;
padding:3px;
}
td, th {
background-color:#ffffff;
padding:7px 20px 7px 10px;
border:1px solid #000066;
}
th {
background-color:#000000; color:#ffffff; 
}
#found {
margin-left:20px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- wrap starts here --&gt;
&lt;div id="wrap"&gt;
&lt;!-- header --&gt;
    &lt;?php require("header.php"); ?&gt;
&lt;!-- menu - links --&gt;
    &lt;?php require("menu.php") ?&gt;
&lt;!-- content-wrap starts here --&gt;
    &lt;div id="content-wrap"&gt;
&lt;!-- sidebar - links --&gt;
    &lt;?php require("sidebar.php"); ?&gt;
        &lt;div id="main"&gt;
&lt;?php
    $result = '&lt;br /&gt;&lt;table summary="Fields"&gt;
&lt;tr&gt;
    &lt;th&gt;Title&lt;/th&gt;
    &lt;th&gt;Author&lt;/th&gt;
    &lt;th&gt;Publisher&lt;/th&gt;
    &lt;th&gt;ISBN&lt;/th&gt;
&lt;/tr&gt;';
$fp = fopen('books.txt','r');
if (!$fp) {echo 'ERROR: Unable to open the book collection.&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'; exit;   
}
$row = 0;
$columns = 5;
while (!feof($fp)) {
     $line = fgets($fp,999);
     $field[$row] = explode("\t", $line);
        $row++;
}
fclose($fp);
$array = count($field) -1;
$loop = -1;
$column = $columns - 1;
$fthis = 'no';
$found = 'no';
$search = strtolower($find_this);
$count = 0;
while ($loop &lt; $array) {
    $loop++;
    $cell = 0;
    while ($cell &lt; $columns) {
        $fields = strtolower($field[$loop][$cell]);
        if (strstr($fields, $search)) {
            $found = 'yes';
            $count++;
            if ($fthis == 'no') {
                $fthis = 'yes';
                echo '&lt;h1 id="found"&gt;Search Result for: "' . $find_this.'" &lt;/h1&gt;'. $result;
        }
    echo '
    &lt;tr&gt;
    &lt;td&gt;'. ucwords($field[$loop][1]) .'&lt;/td&gt;
    &lt;td&gt;'. ucwords($field[$loop][2]) .'&lt;/td&gt;
    &lt;td&gt;'. ucwords($field[$loop][3]) .'&lt;/td&gt;
    &lt;td&gt;'. $field[$loop][4] . '&lt;/td&gt;
    &lt;/tr&gt;';
        break;
    }
    $cell++;
    }
}
    if ($found == 'no') {
        echo '&lt;h1&gt;"'. $find_this . '" was not found in the book collection.&lt;/h1&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="search.php"&gt;&lt;u&gt;Search Again&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;';}
echo '
    &lt;/tr&gt;
    &lt;/table&gt;';
?&gt;
    &lt;br /&gt;
    &lt;br /&gt;
&lt;!-- content-wrap ends here --&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;!--footer starts here--&gt;
    &lt;?php require("footer.php"); ?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
