Table of Contents

Syntax

string count_chars(string $str [, int $mode])

(PHP 4, PHP 5)

$str The string value to be encoded
$mode The type of character counting to perform (see key below)
RETURNS Returns the encoded character string.

Possible Values for $mode

  • 0 = return an array with the ASCII value as the key, and frequency as the value (DEFAULT VALUE)
  • 1 = return an array with the ASCII value as the key, and frequency as the value (omit entries where the frequency is zero)
  • 2 = return an array with the ASCII value as the key, and frequency as the value
  • 3 = return a string that contains all unique characters that were found in the source string ($str)
  • 4 = return a string that contains all unique characters that were NOT FOUND in the source string ($str)

What it Does

Search the source string and compile statistics based on what characters were found in the string and (optionally), which were not. Unless you need to do some statistic analysis on frequency of characters found in a source string, this function will not be of much use to you.

Example

echo count_chars($input, 3);
 
count_chars.txt · Last modified: Apr 18, 2008 - 2:00pm (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki