title: Removing duplicate words from array in PHP
body: <p>Let's say, we have some array like</p>
  
  <pre><code>[
  "red book",
  "red apple",
  "socks",
  "grey socks",
  "red sky",
  "red cross" &lt;----- 4th "red", need to remove this element
  "green cross",
  "blue jeans"
  ]
  </code></pre>
  
  <p>So I need to delete, any array element that contains word repeating more than 3 times in the whole array. So, result for the example above might look like:</p>
  
  <pre><code>[
  "red book",
  "red apple",
  "socks",
  "grey socks",
  "red sky",
   "green cross",
  "blue jeans"
  ]
  </code></pre>
  
  <p>So the word "red" repeated more than 3 times in array. We have to keep up to 3 occurence of any word in array and delete other occurences' elements.</p>
  
  <p>In my opinion, imploding whole array first with space symbol, then exploding into single words. And using <code>array_count</code> might lead to the result. But I can't finish this idea going this way.</p>
  
  <p>Any suggestions?</p>