title: Count occurrence of words and only 1 in the same phrases
body: <p>I have a problem where I need to count the number of times a word occurs in a given array. </p>
  
  <p>I want the code to increase the count of a word (<code>'instagrammm'</code>) by 1 if the word is in the same phrases.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$output = array();
  $buzzes = ['instagramm some text instagramm', 'instagramm some text' , 'instagramm some text' , 'instagramm some text'];
  foreach ($buzzes as $buzz) {
      $flag = 0;
      $words = explode(" ",$buzz);
      foreach ($words as $word)
      {
          $word = mb_convert_case($word, MB_CASE_LOWER, "UTF-8");
          $word = preg_replace('/^[^A-Za-z0-9\-]|[^A-Za-z0-9\-]$/', '', $word);
  
          if(strlen($word) &gt; 2){
              if (array_key_exists($word, $output)){
                      $output[$word]++;
              }else{
                  $output[$word] = 1;
              }    
          } 
      }
  }
  </code></pre>
  
  <p>Here is the expected result:</p>
  
  <pre><code>Array
  (
      [instagramm] =&gt; 4
      [some] =&gt; 4
      [text] =&gt; 4
  )
  </code></pre>