Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $string = readline();
- $input = str_split($string);
- $arr = [];
- for ($i = 0; $i < count($input); $i++) {
- if (array_key_exists(ord($input[$i]),$arr)) {
- $arr[ord($input[$i])] += 1;
- } else {
- $arr[ord($input[$i])] = 1;
- }
- }
- foreach ($arr as $key => $value) {
- echo chr($key) . " -> $value\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment