title: How to count Array based on statement?
body: <p>I use validate php function to filter badword. And my problem is this script can't count badword in a statement that I've input. How to count badword in a statement..? </p>
  
  <p>For example: <strong>You're badword1 and they badword2.</strong><br>
   It's supposed to be 2 badword in that sentence.</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>function validasi($string,$banned_words) {
      foreach($banned_words as $banned_word) {
          if(stristr($string,$banned_word)){
              return false;
          }
      }
      return true;
  }
  $banned_words = array('badword1','badword2','badword3','badword4','badword5','badword6','badword7');
  $teks = $_POST['teks'];
  if (!validasi($teks,$banned_words)) {
      echo count(!validasi($teks,$banned_words));
      echo 'blocked!';
  }else{
      echo 'Text valid';
  }
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form action="validasi.php" method="POST"&gt;
    &lt;input type="text" name="teks"&gt;
    &lt;input type="submit" value="Validasi"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <blockquote>
    <p>1 !blocked.</p>
  </blockquote>
  
  <p><strong>Expected Result</strong></p>
  
  <blockquote>
    <p>2 !blocked</p>
  </blockquote>