(PHP 4, PHP 5)
count_chars — 문자열 안에 사용한 문자에 대한 정보를 반환
string 안에서 모든 바이트 값(0..255)의 수를 세고 여러 방법으로 반환합니다.
검사할 문자열.
선택적인 인수 mode 의 기본값은 0입니다.
mode 에 따른 count_chars()의 반환값은 다음과 같습니다:
Example #1 count_chars() 예제
<?php
$data = "Two Ts and one F.";
foreach (count_chars($data, 1) as $i => $val) {
echo "There were $val instance(s) of \"" , chr($i) , "\" in the string.\n";
}
?>
위 예제의 출력:
There were 4 instance(s) of " " in the string. There were 1 instance(s) of "." in the string. There were 1 instance(s) of "F" in the string. There were 2 instance(s) of "T" in the string. There were 1 instance(s) of "a" in the string. There were 1 instance(s) of "d" in the string. There were 1 instance(s) of "e" in the string. There were 2 instance(s) of "n" in the string. There were 2 instance(s) of "o" in the string. There were 1 instance(s) of "s" in the string. There were 1 instance(s) of "w" in the string.