title: is nested preg_match possible?
body: <p>I'm trying to learn how to get data out of a page with php, I can see how to get everything between tags, but is there a way to get the content of tags within tags?</p>
  
  <p>In the html below,how would I get access to the content of one of the bold spans, the second one for example?</p>
  
  <pre><code>&lt;html&gt;
  &lt;div class="padding10"&gt;
  &lt;span class="bold"&gt;&lt;/span&gt;
  &lt;span class="bold"&gt;&lt;/span&gt;
  &lt;span class="bold"&gt;&lt;/span&gt;
  &lt;span class="bold"&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried the following, which allows me to get the content of the padding10 div but I don't know how to go any further to get the bold spans. Everything I've tried doesn't work.</p>
  
  <pre><code>//gets all
  $file_string = file_get_contents('http://www.test.com/index.html');
  
  //gets all in padding10 div
  preg_match('/&lt;div class="padding10"&gt;(.*)&lt;\/div&gt;/si', $file_string, $padding_10);
  
  //gets all bold spans on padding10 div??
  preg_match_all('/&lt;span class="bold"&gt;(.*)&lt;\/span&gt;/i', $padding_10[1], $spans_10);
  </code></pre>
  
  <p>I'm starting to realise from what I'm reading that this is probably a wrong or inefficient way to be going about this but any help would be great. Thanks.</p>