I can find repeated words in text with this function:
$str = 'bob is a good person. mary is a good person. who is the best? are you a good person? bob is the best?';
function repeated($str)
{
$str=trim($str);
$str=ereg_replace('[[:space:]]+', ' ',$str);
$words=explode(' ',$str);
foreach($words as $w)
{
$wordstats[($w)]++;
}
foreach($wordstats as $k=>$v)
{
if($v>=2)
{
print "$k"." , ";
}
}
}
thats result me like :
bob , good , person , is , a , the , best?
Q : how i can get result repeated words and Multi-part words between space look like :
bob , good , person , is , a , the , best? , good person , is a , a good , is the , bob is