kri*_*hna 0 php string substring
任何人都可以告诉我如何在不使用字符串函数的情况下找到给定字符串中子字符串的出现次数.例如,字符串是" 当男人得到母鸡 "时,我预期的结果是子串' 他 ' 在给定的字符串中出现4次.
del*_*ist 19
substr_count('when the men get the hen', 'he');
Run Code Online (Sandbox Code Playgroud)
http://php.net/manual/en/function.substr-count.php
不使用任何字符串函数?
将自己限制在一组功能中是否有任何真正的意义,这些功能不包括那些专门用于做你想要做的事情的功能?
$string = 'when the men get the hen';
$substring = 'he';
$cArr = explode($substring,$string);
$substring_count = count($cArr) - 1;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11176 次 |
| 最近记录: |