count_chars

mixed count_chars(string string, [int mode]) 

Gets information about the characters used in a string.

Returns:

Array or string containing character information; FALSE if the mode parameter is less than 0 or greater than 4

Description:

count_chars() counts the number of times that an ASCII character occurs within a string and returns the information in one of five possible ways.

The optional parameter mode defaults to 0. Depending on mode , count_chars() returns one of the following:

Value Description
0 An array with the byte value as key and the frequency of every byte as value
1 Like 0, but only byte values with a frequency greater than zero are listed
2 Like 0, but only byte values with a frequency equal to zero are listed

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.