fork(2) download
  1. <?php
  2.  
  3. $str ="iamtheone";
  4.  
  5. // Calculate the frequency table for all letters
  6. $letters = array_fill_keys(range('a', 'z'), ' ');
  7. $freq_count = array_merge(
  8. $letters,
  9. );
  10.  
  11. // Plot the display chart
  12. for ($line = max($freq_count); $line > 0; --$line) {
  13. echo implode(
  14. ' ',
  15. function ($value) use ($line) {
  16. return ($value >= $line) ? '*' : ' ';
  17. },
  18. $freq_count
  19. )
  20. );
  21. echo PHP_EOL;
  22. }
  23. echo implode(' ', array_keys($freq_count)), PHP_EOL;
  24.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
        *                                          
*       *     * *       * * *         *            
a b c d e f g h i j k l m n o p q r s t u v w x y z