Extracting string between <title> and </title> using PHP
<blockquote>
  <p><strong>Possible Duplicates:</strong><br>
  <a href="http://stackoverflow.com/questions/3054347/php5-extracting-a-title-tag-and-rss-feed-address-from-html-using-php-dom-or-reg">(PHP5) Extracting a title tag and RSS feed address from HTML using PHP DOM or Regex</a><br>
  <a href="http://stackoverflow.com/questions/5869925/grabbing-title-of-a-website-using-dom">Grabbing title of a website using DOM</a>  </p>
</blockquote>



<p>I am trying to run through a hundred different html files on my server, and extract the titles for use in another php file.</p>

<p>For reference:</p>

<pre><code>    &lt;title&gt;Generic Test Page&lt;/title&gt;
</code></pre>

<p>What I need is a function that will return the string "Generic Test Page" and stick that into a global variable.</p>

<p>What I am doing right now is simply reading the file into an array called $lines. Foreach $lines as $line, I am testing for the string &lt; title> ... but how do I extract only what's between the > and &lt; /title?</p>

<p>My trouble is that sometimes the original developer decided to elaborate on the title: &lt; title name=title class=title1>, or he put it on three lines instead of one. What in the world? So I can't just strip the first seven characters and the last eight characters. Which would be so nice...</p>

<p>Thank you!!</p>
