且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在字符串中查找确切的字符串

更新时间:2023-02-19 12:18:33

您可以使用正则表达式,并用\b单词边界将单词包围起来

You can do this with regex, and surrounding the word with \b word boundary

preg_match("~\bMures\b~",$string)

示例:

$string = 'Maramures';
if ( preg_match("~\bMures\b~",$string) )
  echo "matched";
else
  echo "no match";