I have a text content that is placed inside $content_array. The result must be one array containing words that are repeated, separated with commas. Now, how do I take out all the words that are repeating in that text, and put them in another array. My code so far (won't work):
$content = strip_tags($content);
// removing all html and php tags from content
$content = strtolower($content);
// transform all characters to lowercase
$content_array = str_word_count($content, 1);
// converting content to array, in order to easier search the content, every member of array is one word
$duplicates = array_unique(array_diff_assoc($content_array, array_unique($content_array)));
// checking for all the words that are repeating and storing them into $duplicates array
while ($val = current($duplicates)){
// going through an array to check for repeated values
if($val >= '3'){
// searching for repeated words, the ones that show up X times and more than X times (X = 3)
$phrase = array($val);
// storing value of repeated word into $phrase array
}
next($duplicates);
// moving on to the next member in array
}
$phrase = implode(",", $phrase);
// separate phrases with comma