int strpos ( string haystack, string needle [, int offset])
Returns the numeric position of the first occurrence of needle in the haystack string. Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used. 
If needle is not found, returns FALSE. 

解决方案 »

  1.   

    strpos
    寻找字符串中某字符最先出现处。
    语法: int strpos(string haystack, string needle, int [offset]);
    返回值: 整数
    内容说明 
    本函数用来寻找字符串 haystack 中的字符 needle 最先出现的位置。值得注意的是 needle 只能是一个字符,中文字等就不适合了。若找不到指定的字符,则返回 false 值。参数 offset 可省略,用来Y表示从 offset 开始找。
      

  2.   

    这是php中文手册里面的一个例子: <?php 
    $findme = 'a'; 
    $mystring1 = 'xyz'; 
    $mystring2 = 'ABC'; $pos1 = stripos($mystring1, $findme); 
    $pos2 = stripos($mystring2, $findme); // Nope, 'a' is certainly not in 'xyz' 
    if ($pos1 === false) { 
    echo "The string '$findme' was not found in the string '$mystring1'"; 
    } // Note our use of ===. Simply == would not work as expected 
    // because the position of 'a' is the 0th (first) character. 
    if ($pos2 !== false) { 
    echo "We found '$findme' in '$mystring2' at position $pos2"; 

    ?>
      

  3.   

    string strstr ( string haystack, string needle)
    如果查不到,则返回false
    s = strstr(字符串,子字符串) === false 表示查不到
      

  4.   

    <?
    $str1="12";
    $str2="54312345564";
    $r=explode($str1,$str2);
    if(count($r)<2)
    {echo"没有包含";}
    else
    {echo"包含了";}
    ?>