PHP strpos check against many

前端 未结 3 1775
野性不改
野性不改 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:21

    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:

    if( preg_match( "/[\:\!&]/", $str ) > 0 ) { return false; }
    

提交回复
热议问题