I am looking to use strpos
to check for many chars in a string, for example:
I would like to separately check for the chars :
,!
, and &
in $string. If any of them are found at any point, return false.
What's the most efficient way to do so? Thanks!
If your post is accurate and what you are trying to do is return FALSE if those strings are found,
strpos()
is not the right function.strpos()
is to find where in a string certain characters (or strings) first appear.If your stated goal is accurate, you probably want something more like this:
Use
preg_match
Example:
Since you don't care about the actual position of the character, you could use regex: