match whole word only without regex

前端 未结 4 1868
既然无缘
既然无缘 2021-01-26 07:27

Since i cant use preg_match (UTF8 support is somehow broken, it works locally but breaks at production) i want to find another way to match word against blacklist. Problem is, i

4条回答
  •  盖世英雄少女心
    2021-01-26 08:01

    You can use strrpos() instead of strpos:

    strrpos — Find the position of the last occurrence of a substring in a string

    $string = "This is a string containing badwords and one badword";
    var_dump(strrpos($string, 'badword'));
    

    Output:

    45
    

提交回复
热议问题