title: PHP: Undefined offset
body: <p>On some pages, i receive the error:</p>
  
  <blockquote>
    <p>PHP Notice: Undefined offset: 1 in
    /var/www/example.com/includes/head.php on line 23</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>if ($r)
  {
  
      list($r1, $r2)=explode(" ", $r[0],2);
      $r1 = mb_strtolower($r1);
      $r3 = " ";
      $r2 = $r3.$r2;
      $r[0] = $r1.$r2;
      $page_title_f = $r[0]." some text";
      $page_title_s = "some text ";
      $page_title = $page_title_s.$page_title_f;
  
  }
  </code></pre>
  
  <p>Line 23 with error:</p>
  
  <pre><code>list($r1, $r2)=explode(" ", $r[0],2);
  </code></pre>
  
  <p>Could you help to understand what could be the problem?</p>
  
  <blockquote>
    <p>Update</p>
  </blockquote>
  
  <p>Thanks all for the help! I partially solved the problem.</p>
  
  <p><code>$r</code> is row in the database.
  The script takes a string and starts to manipulate. Converts uppercase letters to lowercase. And as I understand it, the string must have a space otherwise gets out an error "Undefined offset". Because the script tries to find the first space, and then merge the word before the first space, and the space together with everything that appears after a space. (: I don't understand why he does and there is no way out of this situation if the space in the string no, he just throws an error. ): In general it is a very old and poor engine web store called Shop-Script. Post a full listing of the file, maybe it will be clearer. </p>
  
  <p><a href="http://pastebin.com/Pz1TKpr3" rel="nofollow">http://pastebin.com/Pz1TKpr3</a></p>