3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $text = <<<TEXT rkenbgjengrnekjrgn2ioih34fnorfejk TEXT; $char = array_merge(range("a", "z"), range("A", "Z")); $length = strlen($text); $counter = array(); for($i = 0; $i < $length; $i++) { $item = $text[$i]; if (in_array($item, $char)) { $counter[$item] = isset($counter[$item]) ? $counter[$item] + 1 : 1; } } arsort($counter); var_dump($counter);
based on cnFi3
Output for 7.0.0 - 7.2.0
array(11) { ["n"]=> int(5) ["r"]=> int(4) ["e"]=> int(4) ["k"]=> int(3) ["g"]=> int(3) ["j"]=> int(3) ["i"]=> int(2) ["o"]=> int(2) ["f"]=> int(2) ["b"]=> int(1) ["h"]=> int(1) }
Output for 5.3.21 - 5.6.28
array(11) { ["n"]=> int(5) ["e"]=> int(4) ["r"]=> int(4) ["j"]=> int(3) ["g"]=> int(3) ["k"]=> int(3) ["f"]=> int(2) ["o"]=> int(2) ["i"]=> int(2) ["b"]=> int(1) ["h"]=> int(1) }