Skip to content

Instantly share code, notes, and snippets.

@joshghent
Created February 12, 2019 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshghent/b783767e8bd8fa3660c648e38397debf to your computer and use it in GitHub Desktop.
Save joshghent/b783767e8bd8fa3660c648e38397debf to your computer and use it in GitHub Desktop.
AgedFirsthandKeyboard created by joshghent - https://repl.it/@joshghent/AgedFirsthandKeyboard
$string = "floccinaucinihilipilification";
// First split the string to an array and then get the unique characters so we don't double count
$characters = array_unique(str_split($string));
$count = [];
// Iterate through the characters list and create an associative array of the characters and their count
foreach($characters as $char) {
$count[$char] = substr_count($string, $char);
}
// Order the array
arsort($count);
echo json_encode($count);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment