我想知道是否有任何函数可以在PHP中搜索字符串中的字符串并返回布尔值,告诉字符串是否包含,就像Java中的方法一样?
您可以尝试strpos()
,http://php.net/strpos
$str = "This is a sample string.";
$findMe = "sample";
if (strpos($str, $findMe) !== false) {
// you found me!
}
我想知道是否有任何函数可以在PHP中搜索字符串中的字符串并返回布尔值,告诉字符串是否包含,就像Java中的方法一样?
您可以尝试strpos()
,http://php.net/strpos
$str = "This is a sample string.";
$findMe = "sample";
if (strpos($str, $findMe) !== false) {
// you found me!
}