문자열에 단어가 포함되어 있는지 php 확인
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
문자열에 단어가 포함되어 있는지 php 확인
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
문자열에 php 에 하위 문자열이 포함되어 있는지 확인하는 방법
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
문자열이 포함되어 있는지 php 확인
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}
문자열에 PHP 의 하위 문자열이 포함되어 있는지 확인하십시오
phpCopy<?php
$mystring = "This is a PHP program.";
if (strpos($mystring, "program.") !== false) {
echo("True");
}
?>