Above code will return an array and by using print_r function we have displayed all keys with values of the array. The array will return all chars ( as Key of array ) and its frequency of use ( value of the key in array ) in the given string. If any char is not used then value of that key element will be zero.
With different mode values ( 0 to 4) we will get returns like this
0 Returns array of all chars and its frequency of use. Not used chars also returned with zero value
1 Not used chars are not included only used chars in the string are returned with frequency of uses
2 All chars with zero value ( or all chars which are not used with zero value returned )
3 A string is returned with all used chars
4 A string is returned with all not used chars
We will try some examples here
Setting Mode to 1
By changing the mode value to 1 we will get a big list of all chars with its values. Most of them will have value as zero as we have used few chars.
Here is the code
So you can see the above chars only we have used in our main string.
Interesting applications can be developed by using this function like checking the string for frequency of used chars. How many emails address are present in a string. By just checking frequency of the char @ ( char(64) we can know how many email address are included in the string. Like this many scripts can be developed. Here is the example