하위 문자열이 문자열에있는 경우 php 찾기
$result = strpos("haystack", "needle");
if ($result != false)
{
// text found
}
php 문자열 포함
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
문자열이 포함되어 있는지 php 확인
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}
문자열에 특정 단어가 포함되어 있는지 어떻게 확인합니까?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}