써리원의 이것저것

strpos 문자열 포함 여부를 검사 본문

개발관련

strpos 문자열 포함 여부를 검사

써리_원 2018. 12. 4. 11:25

특정 문자열이 포함되었는지 검사하고자 할 경우 strpos() 함수를 사용한다.


$txtStr = "abcdefghigjklmnopqrstuvwxzy1234567890";  

$searchStr = "bcd";  

  

if(strpos($txtStr, $searchStr) !== false) {  

    echo "문자열이 있습니다.";  

} else {  

    echo "문자열이 없습니다.";  

}  

Comments