title: How to get first three words of a span class in PHP Simple HTML DOM Parser
body: <p>What is the way to get first three words of a span class using <a href="http://simplehtmldom.sourceforge.net/" rel="nofollow noreferrer">PHP Simple HTML DOM Parser</a>.<br>Assuming source code of a fetched page is:</p>
  
  <blockquote>
    <p>Some Text <code>&lt;span class="sos"&gt;</code> Good Better Best <code>&lt;i&gt; Some text&lt;/i&gt; here&lt;/span&gt;</code> Again some text here</p>
  </blockquote>
  
  <p>Using php simple html dom parser we can get all content of a span class like this way:</p>
  
  <pre><code>$data = $html-&gt;find('span class="sos"');
  </code></pre>
  
  <p>so here, <code>$data</code> will declare full content of that span class.<br>What i wanna do is to get only the first three words of a span class in a new variable, so in this case it should be:</p>
  
  <pre><code>$new_data = 'Good Better Best';
  </code></pre>
  
  <p>How to do it?<br>PHP Simple HTML DOM Parser <a href="http://simplehtmldom.sourceforge.net/manual.htm" rel="nofollow noreferrer">Manual</a></p>