title: PHP error handling- Undefined offset
body: <p>I've checked my apache error logs, and I see multiple messages like this:</p>
  
  <pre><code>client 108.162.246.190] PHP Notice:  Undefined offset: 4 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 5 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 5 in /var/www/html/search.php on line 143
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 6 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 6 in /var/www/html/search.php on line 143
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 7 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 7 in /var/www/html/search.php on line 143
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 8 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 8 in /var/www/html/search.php on line 143
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 9 in /var/www/html/search.php on line 142
  [Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice:  Undefined offset: 9 in /var/www/html/search.php on line 143
  </code></pre>
  
  <p>And code around 142-143 lines looks like this (the actual 142-143 lines are implode ones):</p>
  
  <pre><code>    if ($nuorodoshut != NULL)
          {
              foreach ($nuorodoshut as $key =&gt; $nuorodahut) 
              {   
              $keywords = explode(' ', $qsvarus);
              $title[$key] = preg_replace('/\b('.implode('|', $keywords).')\b(?![^&lt;]*[&gt;])/i', '&lt;b&gt;$0&lt;/b&gt;', $title[$key]);
              $infoo[$key] = preg_replace('/\b('.implode('|', $keywords).')\b(?![^&lt;]*[&gt;])/i', '&lt;b&gt;$0&lt;/b&gt;', $infoo[$key]);
              echo '&lt;tr&gt;&lt;td&gt;&lt;h3&gt;';
              echo str_replace('&lt;a href="/', '&lt;a href="/host/', $nuorodahut-&gt;innertext) . '&lt;/h3&gt;';
              echo $aprasymashut[$key]-&gt;innertext . '&lt;br&gt;';
  
              }
  }
  </code></pre>
  
  <p>I just can't handle this error. Any help would be appreciated</p>