count_chars (PHP 4, PHP 5, PHP 7, PHP 8) count_chars — Return information about characters used in a string
<?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.
";
}
?>