substr_count()函数用于计算子字符串的数量。
substr_count(str,substr,begin,len)
str − 要检查的字符串
substr − 要搜索的字符串
begin − 在字符串中开始搜索的位置
len − 搜索的长度
substr_count() 函数返回字符串中子字符串出现的次数。
The following is an example −
实时演示
<?php $str = 'This is our example!'; echo strlen($str); echo ""; echo substr_count($str, 'our'); ?>
20 1