Created
December 18, 2011 09:34
-
-
Save aquilax/1492862 to your computer and use it in GitHub Desktop.
row
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
<?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