Find the occurrence of backslash in a string

后端 未结 3 1300
無奈伤痛
無奈伤痛 2021-01-25 05:28

If my string is : aud\\ios, how do i check it out for the presence of \\ in it?

I tried using preg_match(\'\\\\\' , $string) but

3条回答
  •  余生分开走
    2021-01-25 05:45

    I use this function a lot, you can easily check if a string contains

    function StringContains($the_string,$contains)
    {
        return strpos($the_string, $contains) !== FALSE;
    }   
    

    check it out: http://3v4l.org/LrDBd

    of course you have to escape the backslash when calling the function like this StringContains('aud\ios','\\');

提交回复
热议问题