[英]How to count occurrences of special type of character in string in php
I have a string 我有一个弦
Hobbies#14285723739878005#reading#Reading
I need the count of number of occurrence of '#' in the string. 我需要计算字符串中“#”的出现次数。 How to get that?
如何获得?
try this code: 试试这个代码:
<?php
echo substr_count("Hobbies#14285723739878005#reading#Reading","#");
?>
Output:- 输出: -
3
For your reference Click Here 供您参考,请点击这里
substr_count() should do what you need: substr_count()应该可以满足您的需求:
http://www.w3schools.com/php/func_string_substr_count.asp http://www.w3schools.com/php/func_string_substr_count.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.