count_chars.php : count_chars « String « PHP






count_chars.php

 
<?php
   $sentence = "this is a test";
   $chart = count_chars($sentence, 1); 

   foreach($chart as $letter=>$frequency)
      echo "Character ".chr($letter)." appears $frequency times<br />";
?>
  
  








Related examples in the same category

1.mixed count_chars ( string str [, int mode] ) returns an array containing the letters used in that string and how many times each letter was used.