12.1. Strings
For the most part, the string functions create strings from other strings or report the properties of a string.
array count_chars(string data, integer mode)string count_chars(string data, integer mode)
The count_chars function (Listing 12.1) analyzes a string by the characters present. The mode argument controls the return value as described in Table 12.1. See Figure 12.1.
Mode | Description |
---|---|
0 | Returns an array indexed by ASCII codes. Each element is set with the count for that character. |
1 | Returns an array indexed by ASCII codes. Only characters with positive counts appear in the array. |
2 | Returns an array indexed by ASCII codes. Only characters with zero counts appear in the array. |
3 | Returns a string containing ... |
Get Core PHP Programming, Third Edition 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.