title: PHP Notice - Undefined Offset 1
body: <p>I'm still pretty new with PHP. I saw other posts about this notice, but none seemed to speak to my situation. I am attempting to list the Titles (h2 element) from another page. While I have succeeded in that endeavor (the titles are listing), I am also getting the following Notice:</p>
  
  <p>'Notice: Undefined offset: 1 in /Users/jessenichols/Sites/HCS/news.php on line 26'</p>
  
  <pre><code>&lt;?php
          function getTitle($Url){
              $str = file_get_contents($Url);
              if(strlen($str)&gt;0){
                  preg_match("/\&lt;h2\&gt;(.*)\&lt;\/h2\&gt;/",$str,$title);
                  return $title[1];
              }
          }
          if ($handle = opendir('news')) {
              while (false !== ($entry = readdir($handle))) {
                  if ($entry != "." &amp;&amp; $entry != "..") {
                      echo '&lt;p class="article_selector"&gt;'.getTitle('news/'."$entry").'&lt;/p&gt;';
                  }
              }
              closedir($handle);
          }
      ?&gt;
  </code></pre>