title: strip_tags, remove javascript
body: <p>I have this problem with the code i'm running right now.</p>
  
  <p>My code is that I enter an URL and when i click submit it removes all tags. I use <code>strip_tags</code> for that one. And then I use <code>preg_match_all("/((?:\w'|\w|-)+)/", $contents, $words);</code> which creates and array of every word. I then have a foreach loop which will count all words and then place it in a table with another foreach loop.</p>
  
  <p>The problem is for example. Say I enter an URL which has the following content:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;titel1&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="div1"&gt;
              &lt;h1 class="class2"&gt;
                  Testpage-h1
              &lt;/h1&gt;
              &lt;p&gt;
                  Testpage-p
              &lt;/p&gt;
          &lt;/div&gt;
          &lt;script&gt;
              alert('hallo');
              document.getElementById('class2');
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This will echo out the following using my code:</p>
  
  <pre><code>document         1
  getElementById1  1
  class2'          1
  hallo            1
  alert            1
  Testpage-h1      1
  Testpage-p       1
  titel1           1
  </code></pre>
  
  <p>(sorry for placing this as 'code' but it wouldn't let me use breaks otherwise, or place the numbers under eachother)</p>
  
  <p>My problem with this is that it shouldn't show what is between the <code>&lt;script&gt;&lt;/script&gt;</code> tags, because that has no use for me anyway. Is there a solution for this matter?</p>
  
  <p>I've tried such things as sanitize filterering but this didn't help me.</p>