Get information about characters used in a string in PHP
Description
The following code shows how to get information about characters used in a string.
Example
/* w w w.j av a 2s . c om*/
<?php
$data = "Two Ts and one F.";
foreach (count_chars($data, 1) as $i => $val) {
echo "There were $val instance(s) of \"" , chr($i) , "\" in the string.\n";
}
?>
The code above generates the following result.