PHP strpos check against many

前端 未结 3 1781
野性不改
野性不改 2021-01-27 06:39

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 :,!, a

3条回答
  •  滥情空心
    2021-01-27 07:30

    If any of them are found, return false.

    Since you don't care about the actual position of the character, you could use regex:

    preg_match("/[:!&]/", $str); // 1 if found, 0 if none found
    

提交回复
热议问题