PHP-如何检查字符串是否包含子字符串PHP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP-如何检查字符串是否包含子字符串PHP相关的知识,希望对你有一定的参考价值。

Once in a while we need to check whether a string contains substring, some other string or characters or a value. Checking for existence of a string (or substring) inside another string is easier than it might seem. The following article describes how to check for whether a string contains string in php, or simply said how to find string within string in PHP.
  1. $intPos = strpos($strHaystack,$strNeedle);
  2.  
  3. if( $intPos === false ) {
  4. // string strNeedle NOT found in strHaystack
  5. } else {
  6. // string strNeedle found in strHaystack
  7. }

以上是关于PHP-如何检查字符串是否包含子字符串PHP的主要内容,如果未能解决你的问题,请参考以下文章