title: Undefined offset in PHP
body: <p>When I tried following code:</p>
  
  <pre><code>function getusername($input){
      //parse the result
      preg_match("/&lt;username&gt;(.*)?&lt;\/username&gt;/", $input, $username);
      return $username[1]; // Line 4
  }  
  </code></pre>
  
  <p>It gave me this error:</p>
  
  <blockquote>
    <p>Undefined offset on line 4.</p>
  </blockquote>