title: php array 6 sided Dice Roll Tally issue
body: <p>I was hoping someone could figure out why my code is not working for a 6-sided dice tallying the numbers for 6000 rolls using arrays.</p>
  
  <pre><code>&lt;?php
  //  main    //////////////////////////////////
  //$throw_dice = array();
  //$tally = array();
  echo "debug - code runs to this point&lt;br&gt;\n";
  
  $throw_dice = throw_dice($throw_dice);
  $tally = tally_results($throw_dice);
      echo "debug with tally: $tally[4]&lt;br&gt;\n";
      exit;
  $line = print_table($tally);
  echo $line;
  
  
  // functions ////////////////////////////////
  
  function throw_dice ($f_throw_dice) {
      /*  required pseudocode:
          for loop from 1 to 6000
              populate each element with random number 1 - 6
          end for loop
          return array
      */
  for ($i = 0; $i &lt; 6000; $i++) {
      $f_throw_dice[] = mt_rand(1,6);
  }
  return array($f_throw_dice);
  }
  
  function tally_results ($f_throw_dice) {
      /*  
          use increment system example shown below with associative array:
              $numbers = array(1, 2, 2, 1, 2, 1, 1, 1, 2)
              foreach ($numbers as $number) {$tally[$number]++}
              will give 5 for $tally[1] and 4 for $tally[2]
      */
  //$tally = array('1' =&gt; 1,'2' =&gt; 2,'3' =&gt; 3,'4' =&gt; 4,'5' =&gt; 5,'6' =&gt; 6,);
  //$numbers = array($f_throw_dice);
  //$tally[0] = '1';
  //$tally[1] = '2';
  //$tally[2] = '3';
  //$tally[3] = '4';
  //$tally[4] = '5';
  //$tally[5] = '6';
  $tally = array();
  foreach ($f_throw_dice as $number) 
      {
          $tally[$number]++;
          echo $tally;
  
      }
  }
  
  
  function print_table($f_tally) {
      /*  required pseudocode:
          note: concatenate entire formatted printout in one variable $line
          Can start this way:
              $line = "&lt;pre&gt;";
              $line .= sprintf ("DIE #%10s", 'OCCURS');
              $line .= "\n===============\n";
          sort $f_tally by key
          foreach loop 
              concatenate $line with another $f_tally element using the 
                  sprintf format from last assignment
          end loop
          return $line
      */
      $line = "&lt;pre&gt;";
      $line .= sprintf ("DIE #%10s", 'OCCURS');
      $line .= "\n===============\n";
      ksort ($f_tally);
      echo '&lt;ul&gt;';
      foreach ($f_tally as $numbers =&gt; $tally) {
          echo '&lt;pre&gt;',
          $line .= sprintf('%s        %s', $numbers, $tally), '&lt;/pre&gt;';
         // echo '&lt;li&gt;$numbers ($tally)&lt;/li&gt;';
      }
      echo '&lt;/ul&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>The result should look similar to this:</p>
  
  <pre><code>DIE #   OCCURS
  ==============
  1         1000
  2          990
  3         1038
  4         1012
  5         1007
  6          953
  </code></pre>