PHP Character and Word Count
PHP Character and Word Count
This program written with PHP will echo the character count for each character as well as the work count for the entered string.
PHP
<?php
$string = "this php code will tell us the frequency of each letter in this string including spaces";
$words = str_word_count($string);
$chart = count_chars($string, 1);
foreach($chart as $letter=>$frequency) echo "Character ".chr($letter)." appears $frequency times<br />";
echo "Total words in string: $words";
?>
Comments
Post a Comment