title: php file - get html content into array by tag
body: <hr>
  
  <p><strong>UPDATE: This code works so far. Still tweeking.</strong></p>
  
  <pre><code>$trimmed = file('http://www.edvizenor.com/mercy/love/dm8.php');
  
  foreach ($trimmed as $line_num =&gt; $line) 
  {
  
  
  if(preg_match("/&lt;td class=\"num\"&gt;/",  $trimmed[$line_num], $matches))
  
    {   
   $num++;
    }
  
  
    $Content[$num] .= $trimmed[$line_num];
  
  
  
  
  }
  
  // Example array! 
  echo $Content[6];
  </code></pre>
  
  <p>////</p>
  
  <h2>END UPDATE</h2>
  
  <hr>
  
  <p>I am trying to get table contents into an array using php. I would like to get all the paragraphs after each number into an array.</p>
  
  <p>Here is the url: <a href="http://edvizenor.com/mercy/love/dm8.php" rel="nofollow">http://edvizenor.com/mercy/love/dm8.php</a> </p>
  
  <p>I need to have the text content of each paragraph number into an array as well as the paragraph number too. Once I have that then I want to save them in a folder into a txt file named by there paragraph number.</p>
  
  <p>For example after I get the contents into the correct array then if I want to call paragraph #832 then I would do something like this:</p>
  
  <pre><code>$par = file_get_contents("353.txt"); 
  // Need code to get only number
  echo $num;
  echo "&lt;br&gt;";
  echo $par;
  
  // should echo out:
  353 
  When Mother left for the chapel and I stayed to set the room in order,
  I heard these words: Tell all the sisters that I demand that they live
  in the spirit of faith towards the superiors at this present time. I 
  begged my confessor to release me from this duty. 
  </code></pre>
  
  <p>I thought about putting the whole content into a string and "exploding";</p>
  
  <pre><code>$Content = file_get_contents("http://edvizenor.com/mercy/love/dm8.php");
  $ContentArray = explode("&lt;td class=\"num\"&gt;", $Content);
  </code></pre>
  
  <p>but this is getting complicated. So I stopped it.</p>
  
  <p>Any ideas on the best way to do this. I have a total of 1868 paragraphs and content. So copy and paste would be a lot of work. Thankfully, all the html is written the same so I should be able to find a pattern and do what I want accordingly. But I can't figure it out so I turn to the wise ones on StackOverflow :)</p>