函数 - PHP判断 A字符串 中是否存在 B字符串

「函数」 PHP判断 A字符串 中是否存在 B字符串

简单粗暴

转载链接

php 字符串中是否包含指定字符串的多种方法

strpos

返回 needle 在 haystack 中首次出现的数字位置。
strpos( string $haystack , mixed $needle , int $offset = 0 ) : int

// 实例
$a_string = "welcome to China";
$b_string = "China";

if (strpos($a_string, $b_string) !== false) {
     
     
   echo "存在";
} else {
     
     
   echo "不存在";
}

Guess you like

Origin blog.csdn.net/qq_35453862/article/details/115913901