用explode然后计算数组元素个数?
在直接的函数吗?
回复讨论(解决方案)
mb_substr_count
$s = '判断一个字符串中是否存在两个或以上的子字符串';if(preg_match('/(.+).*\\1/u', $s)) echo 'yes';//看看都匹配到了什么preg_match_all('/(.+).*\\1/u', $s, $r);print_r($r);
yes
Array
(
[0] => Array
(
[0] => 个字符串中是否存在两个
)
[1] => Array
(
[0] => 个
)
)
注意:gbk 不可这么写!
虽然去掉 u 修饰符后可用于 gbk,但结果并不准确
已解决,谢谢楼上两位版主。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn