0

Just want a really simple way to check a textarea string for all characters or stings in a variable delimited by pipes...

Update: Yeah it doesnt have to be in pipes, thats just how I stored the different characters in the database. All it needs to be is a solid example of how to check the text for whatever you need. At the moment ive got a long list of strpos() statements, which I suppose could be looped from an array but nobody seems to have come up with a way to check against anything a bot can put into a message form, least not that I found :(

  $spmChk = 'clean';

  $textarea = 'This i$ some text for the textªrea';
  
  // needs to be abe to process any characters
  $spamChars = 'href|http|#|¥|²|æ|é|Hello. And Bye.|£|$|ˆ|ª';

  // my attempt
  // search textarea for spam characters
  if (preg_match("/$spamChars/u", $textarea)) {
     
      $spmChk = 'you got spam :)';
  }

  echo $spmChk;
tard
  • 1
  • 1
  • 1
    The dollar sign is a special char, you have to escape it `\$` – The fourth bird Apr 17 '21 at 06:33
  • Ah thank you. For the variable inside the function do you mean? preg_match("/\$spamChars.... Like that? – tard Apr 17 '21 at 07:16
  • 1
    I mean in this part `$spamChars = 'href|http|#|¥|²|æ|é|Hello. And Bye.|£|\$|ˆ|ª';` You are using an alternation `|` to match one of the listed alternatives, but one of the alternatives is `$` which asserts the end of the string. If you want to match a dollar sign, you have to escape it to match it literally. – The fourth bird Apr 17 '21 at 07:17

0 Answers0