<?php
$str1 = "abc";
$str2 = "sadfsdabcsdfabc335liuabclkj300909abcdsf";
echo count(explode($str1,$str2))-1;
?>

解决方案 »

  1.   

    有!substr_count例
    <?php
    $str1 = "abc";
    $str2 = "sadfsdabcsdfabc335liuabclkj300909abcdsf";
    echo substr_count($str2,$str1);
    ?>
      

  2.   

    substr_count这个函数俺还刚发现,8错!
      

  3.   

    建议大家在提问前先看看php手册,如果没有再提问
      

  4.   

    厉害
    substr_count都可以知道
      

  5.   

    <?php
    echo substr_count("This is a test", "is"); // prints out 2
    ?>
      

  6.   

    楼主应该先查查php手册的
    上面都写着呢...
      

  7.   

    真是多谢,我不是没有看手册,而是在手册里面没有找到,我认为这个函数怎么也应该用 str_ 开头,比如 str_search,没有想到……唉!