virtuexru Posted March 28, 2007 Share Posted March 28, 2007 How would I be able to detect, something like this is input: "aaaaaaaaaaaaaaa dddddddddddddd" So basically I need something to catch a string over say 10 characters without spaces. Quote Link to comment Share on other sites More sharing options...
effigy Posted March 28, 2007 Share Posted March 28, 2007 <pre> <?php $tests = array( 'a', 'aaa', 'aaaaaa', 'aaaaaaaaa', 'aaaaaaaaaaaa', 'aaaaaaaaaaaaaaa', 'b aa', 'bbb aaaaaa', 'bbbbbb aaaaaaaaa', 'bbbbbbbbb aaaaaaaaaaaa' ); foreach ($tests as $test) { echo $test, '<br> '; echo preg_match('/(.)(?=\1{9})/', $test) ? 'Spam' : 'Not Spam'; echo '<hr>'; } ?> </pre> Quote Link to comment Share on other sites More sharing options...
Lytheum Posted March 29, 2007 Share Posted March 29, 2007 function spamcheck($text,$nr=10) { $spamtext=explode(" ",trim($text)); $newtext=array(); foreach($spamtext as $k=>$txt) { if (strlen($txt)>$nr) { $txt=wordwrap($txt, $nr, "-", 1); } $newtext[]=$txt; } return implode(" ",$newtext); } So.. $spam = 'Spaaaaaaaaaaaaaaaam'; spamtext($spam); Would Return -> "Spaaaaaaa- aaaaaaaam" Just trying to help ($nr is how many characters you want it to detect) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.