title: php get body from html page
body: <p>I want to strip some html-body code from de full-html code.</p>
  
  <p>I use the script below.</p>
  
  <pre><code>&lt;?php       
      function getbody($filename) {
        $file = file_get_contents($filename);
  
        $bodystartpattern = ".*&lt;body&gt;";
        $bodyendpattern = "&lt;/body&gt;.*";
  
        $noheader = eregi_replace($bodystartpattern, "", $file);
  
        $noheader = eregi_replace($bodyendpattern, "", $noheader);
  
        return $noheader;
      }
      $bodycontent = getbody($_GET['url']);
  ?&gt;
  </code></pre>
  
  <p>But in some cases the tag <code>&lt;body&gt;</code> doesn't exist literally, but the tag could be <code>&lt;body style="margin:0;"&gt;</code> or something. Who can tell me what is the solution to find the body-tag in this case by using a regular expression in the $bodystartpattern which looks for the closing-">" of the opening-body-tag?</p>