$val
"); //} //////////////////////// //DISPLAY RESLUTS //////////////////////// //PRINT OUT THE HEADER FOR THE TABLE OF RESULTS print("
$whatTitle
"); //PRINT THE DATA IN A TABLE DATAS... while (list ($key, $val) = each ($letterCounts)) { $letter = $key; $count = $letterCounts[$letter]; $percent = $letterPercents[$letter]; if ($count == 0) break; print (""); } //PRINT FOOTER FOR THE TABLE print ( "
  $letter$count $percent% 
" ); } //////////////////////////////////////////////////////////////////////////////////// // // basicLetters() // // returns array of the basic letters to look for here (0-9,a-z,A-Z) // //////////////////////////////////////////////////////////////////////////////////// function basicLetters(){ return array('1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); } //////////////////////////////////////////////////////////////////////////////////// // // countMatches // array = countMatches(array whatItems, string whatText); // // searches whatText for each item in whatItems, returns an array of counts // //////////////////////////////////////////////////////////////////////////////////// function countMatches($whatItems, $whatText){ $letterCounts = Array(); for ($n = 0; $n < count($whatItems); $n++){ $letter = $whatItems[$n]; $count = preg_match_all ( "/$letter/", $whatText, $matches); //use preg_match_all to count occurences. $letterCounts[$letter] = $count; // print ("letter: $letter, count: $count
"); } return $letterCounts; } //////////////////////////////////////////////////////////////////////////////////// // // counts2Percents // array = counts2Percents(array counts, total); // // // calculates percentage of total for each count returns array of percents // //////////////////////////////////////////////////////////////////////////////////// function counts2Percents($countArray, $outOf){ $percentArray = Array(); while (list ($letter, $val) = each ($countArray)) { $count = $countArray[$letter]; $percent = ($count/$outOf)*100; //convert it to a percent $percent = sprintf("%2.1f",$percent); //format the percent nice and pretty $percentArray[$letter] = $percent; //store it } return $percentArray; } //////////////////////////////////////////////////////////////////////////////////// // // backwardsAsort // array = countMatches(array whatArray); // // // asort does the sorting for us, but gives it backwards. array_reverse didn't do the trick, so i negate all the counts, sort, and then negate again (hack, but works) // //////////////////////////////////////////////////////////////////////////////////// function backwardsAsort($whatArray){ // asort does the sorting for us, but gives it backwards. array_reverse didn't do the trick, so i negate all the counts, sort, and then negate again (hack, but works) while (list ($key, $val) = each ($whatArray)) { $whatArray[$key] = - $whatArray[$key]; } asort($whatArray); while (list ($key, $val) = each ($whatArray)) { $whatArray[$key] = - $whatArray[$key]; } return $whatArray; } //////////////////////////////////////////////////////////////////////////////////// // // build2LetterCombos // // builds each 2part combo from the basic Letters // //////////////////////////////////////////////////////////////////////////////////// function build2LetterCombos(){ $singleLetterArray = basicLetters(); $posA = 0; $letterArray = array(); for ($pos1 = 0; $pos1 < count($singleLetterArray); $pos1++){ for ($pos2 = 0; $pos2 < count($singleLetterArray); $pos2++){ $letterArray[$posA] = $singleLetterArray[$pos1].$singleLetterArray[$pos2]; $posA++; } } return $letterArray; } function fillText(){ if ($_POST['whatText'] != ""){ print(stripslashes($_POST['whatText'])); }else{ if (rand()%2 == 1){ print(" 10.15 Saturday night And the tap drips Under the strip light And I'm sitting In the kitchen sink And the tap drips Drip drip drip drip drip drip drip drip Waiting For the telephone to ring And I'm wondering Where she's been And I'm crying For yesterday And the tap drips Drip drip drip drip drip drip drip drip "); }else{ print(" I would say I'm sorry If I thought that it would change your mind But I know that this time I've said too much Been too unkind I try to laugh about it Cover it all up with lies I try and Laugh about it Hiding the tears in my eyes 'cause boys don't cry Boys don't cry "); } } } ?> VK: Volcano Kit IO

This script looks through your text and finds the most often used letters and 2 letter combos.

Developed for Process Type Foundry for use in designing their font Lingua.

Useful if you are making ligatures or if you like to do a good deal of code breaking.

Enter Your Text:


Letter Frequency:", basicLetters()); ?>
Combo Frequency:", build2LetterCombos()); ?>