Primaxm

Untitled

Sep 23rd, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. <?php
  2. $string = readline();
  3. $input = str_split($string);
  4.  
  5. $arr = [];
  6.  
  7. for ($i = 0; $i < count($input); $i++) {
  8. if (array_key_exists(ord($input[$i]),$arr)) {
  9. $arr[ord($input[$i])] += 1;
  10. } else {
  11. $arr[ord($input[$i])] = 1;
  12. }
  13. }
  14.  
  15. foreach ($arr as $key => $value) {
  16. echo chr($key) . " -> $value\n";
  17. }
Advertisement
Add Comment
Please, Sign In to add comment