PHP程序查找字符串中的字符数
为了找到字符串中的字符数,PHP代码如下-
示例
<?php
$my_string = "Hi there, this is a sample ";
$len = mb_strlen($my_string);
print_r("The number of characters in the string is ");
echo $len;
?>输出结果
The number of characters in the string is 27
上面定义了一个字符串,该字符串之间的空格超过了所需的空格-
$my_string = "Hi there, this is a sample ";
接下来,使用“strlen”函数计算字符串的长度。该长度分配给变量。这将给出字符串中存在的字符,包括空格-
$len = mb_strlen($my_string);
然后将计算出的长度打印在屏幕上-
print_r("The number of characters in the string is ");
echo $len;热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短