Created
February 12, 2019 21:46
-
-
Save joshghent/b783767e8bd8fa3660c648e38397debf to your computer and use it in GitHub Desktop.
AgedFirsthandKeyboard created by joshghent - https://repl.it/@joshghent/AgedFirsthandKeyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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