0

for example I might:

$exclude_values = ['/','.'];
$check_string = 'asdf/';
$return = 'VALID';
foreach($exclude_values as $value)
{
  if(strpos($value,$check_string) != FALSE)
  {
   $return = 'INVALID';
  }
}

return $return;

Is there a better way to do this? I've seen examples of single checks on stack just not multiple values

ajameswolf
  • 1,650
  • 4
  • 21
  • 43

1 Answers1

1

I can't recommend any string searching function outside the multibyte or PCRE lib, because they are not always utf-8 compatible, and you'll have strange errors sooner or later.

In your case a regex is a much better solution:

return !preg_match('%[/\.]%usD', $check_string);
inf3rno
  • 24,976
  • 11
  • 115
  • 197