title: Compare two strings and count how many times two words match
body: <p>I have two strings such as:</p>
  
  <pre><code>$string1 = 'Hi how are you today';
  $string2 = 'how' AND 'today';
  </code></pre>
  
  <p>$string1 could be anything as it gets it's content through a loop.</p>
  
  <p>I want to be able to count how many times the two words in $string2 appear in $string1.  Both words have to exist, in any order.</p>
  
  <p>This is what I have so far.  But it only checks if "text" exists.  How can I change it to check if "text" and "text2" exist in any order.</p>
  
  <pre><code>$sitesToCheck = array("http://mysitecom.com", "http://mysitetwocom.com"));
  
  foreach ($sitesToCheck as $site) {
      $html = file_get_html($site);
      foreach ( $html-&gt;find('.table tr td.span8') as $element ) {
          $list .=  $element-&gt;plaintext;
          $item_count = count(explode('text', $list));
      }
  }
  </code></pre>
  
  <p>Thanks,</p>