title: Get a specific content block of element using URL in PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php">How to parse and process HTML with PHP?</a>  </p>
  </blockquote>
  
  
  
  <p>I know file_get_contents(url) method, but i wanted is that maybe using file_get_contents(url) at first to pull the contents of a page then is there something methods/functions that can extract or get a certain block of contents from the contents that you get using file_get_contents(url)? Here's a sample:</p>
  
  <p>so the code will be like this: </p>
  
  <pre><code>$pageContent = file_get_contents('http://www.pullcontentshere.com/');
  </code></pre>
  
  <p>and this will be the output of <code>$pageContent</code></p>
  
  <pre><code>&lt;html&gt; &lt;body&gt;
      &lt;div id="myContent"&gt;
          &lt;ul&gt;    
              &lt;li&gt;&lt;/li&gt;
              &lt;li&gt;&lt;/li&gt;
              &lt;li&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt; 
  &lt;/body&gt; &lt;/html&gt;
  </code></pre>
  
  <p>Maybe you have something to suggest or have in mind how to specifically extract the <code>&lt;div id="myContent"&gt;</code> and the entire children of it?</p>
  
  <p>So it will be something like this:</p>
  
  <pre><code>$content = function_here($pageContent);
  </code></pre>
  
  <p>so the output would be like this:</p>
  
  <pre><code>        &lt;div id="myContent"&gt;
              &lt;ul&gt;    
                  &lt;li&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt; 
  </code></pre>
  
  <p>Answers are greatly appreciated!</p>