PHP count_chars() Function

PHP count_chars() function returns information about characters used in a string.

Syntax

count_chars() Function Parameter

ParameterDescription
str :Required parameter. The examined string.
mode :Optional parameter. Returns modes. 0 is default. different modes are following:

  • 0 - an array with the ASCII value as key and number of occurrences as value
  • 1 - same as 0 but only byte-values with a frequency greater than zero are listed.
  • 2 - same as 0 but only byte-values with a frequency equal to zero are listed.
  • 3 - a string containing all unique characters is returned.
  • 4 - a string containing all not used characters is returned.

count_chars() Function Return Value

Return Value :Returns one of the mode mentioned above.

count_chars() Function Example 1

count_chars() Function Example 2