I have a site where users can put in a description about themselves.
Most users write something appropriate but some just copy/paste the same text a number of times (to
Another idea would be to use substr_count iteration:
$str = "Love a and peace love a and peace love a and peace love a and peace love a and peace love a and peace";
$rep = "";
$str = strtolower($str);
for($i=0,$len=strlen($str),$pattern=""; $i<$len; ++$i) {
$pattern.= $str[$i];
if(substr_count($str,$pattern)>1)
$rep = strlen($rep)strlen($str)/5) echo "Repetitive string alert!";
else echo "String seems to be non-repetitive.";
echo " Longest pattern found: '$rep'";
Which would output
Repetitive string alert! Longest pattern found: 'love a and peace love a and peace love a and peace'