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. Link to comment https://forums.phpfreaks.com/topic/44692-how-to-stop-spam-several-characters-in-a-row-no-spaces/ 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> Link to comment https://forums.phpfreaks.com/topic/44692-how-to-stop-spam-several-characters-in-a-row-no-spaces/#findComment-217034 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) Link to comment https://forums.phpfreaks.com/topic/44692-how-to-stop-spam-several-characters-in-a-row-no-spaces/#findComment-217111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.