PHP count_chars()函数讲解

(编辑:jimmy 日期: 2024/10/7 浏览:2)

PHP count_chars() 函数

实例

返回一个字符串,包含所有在 "Hello World!" 中使用过的不同字符(模式 3):

<"Hello World!"; 
echo count_chars($str,3); 
"htmlcode">
count_chars( _string,mode_ )

PHP count_chars()函数讲解

PHP count_chars()函数讲解

实例 1

返回一个字符串,包含所有在 "Hello World!" 中未使用过的字符(模式 4):

<"Hello World!"; 
echo count_chars($str,4); 
"htmlcode">
<"Hello World!"; 
print_r(count_chars($str,1)); 
"htmlcode">
<"PHP is pretty fun!!"; 
$strArray = count_chars($str,1); 
foreach ($strArray as $key=>$value) 
{ 
echo "The character <b>'".chr($key)."'</b> was found $value time(s)<br>"; 
} 
?>

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接