O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Table 12.1. count_chars Modes
ModeDescription
0Returns an array indexed by ASCII codes. Each element is set with the count for that character.
1Returns an array indexed by ASCII codes. Only characters with positive counts appear in the array.
2Returns an array indexed by ASCII codes. Only characters with zero counts appear in the array.
3Returns a string containing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required