Strings

For the most part, the string functions create strings from other strings or report about the properties of a string. The exception is the eval function, which executes a string as if it were a line of code in your PHP script.

array count_chars(string data, integer mode)string count_chars(string data, integer mode)

The count_chars function analyzes a string by the characters present. The mode argument controls the return value. Modes 0, 1 and 2 return an array. Modes 3 and 4 return a string. If mode is left out, mode 0 is used.

If mode is 0, an array is returned indexed by ASCII codes, 0–255. Each element is set with the count for that character. If mode is 1, only the elements with count greater than zero are returned. If mode is 2, ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites 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.