Skip to content

Instantly share code, notes, and snippets.

@aquilax
Created December 18, 2011 09:34
Show Gist options
  • Save aquilax/1492862 to your computer and use it in GitHub Desktop.
Save aquilax/1492862 to your computer and use it in GitHub Desktop.
row
<?php
$string = 'tabdaderdty';
$counter = array_fill(0, 255, 0);
for ($i = 0; $i < strlen($string); $i++) {
$counter[ord($string[$i])]++;
}
arsort($counter);
echo $string.PHP_EOL;
foreach($counter as $k => $v){
if ($v == 0) {
break;
}
echo str_repeat(chr($k), $v);
}
echo PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment