title: Can't get arrays to work in PHP
body: <p>So I'm having a problem with my code here:</p>
  
  <pre><code>$answerString = $_GET['answers'];
  
  $questionsString = $_GET['questions'];
  
  $question = array();
  
  $answer = explode(',', $answerString);
  
  $question = explode(',', $questionsString);
  
  $score = 0;
  
  for($index = 0; $index &lt;= 9; $index++)
  {
      $query = "SELECT * FROM questions WHERE id = '$question[$index]'";
      $result = mysql_query($query);
      $rows = mysql_fetch_array($result, MYSQL_ASSOC);
  
      $cans = $rows['answer'];
      $test = array($cans);
      $ans = array();
      foreach ($test as $correct){
      $ans[] = $correct;
      }
      print_r($ans);
  
              if($answer[$index] == $rows['answer'])
      {
          $score++;
      }
  
  }
  </code></pre>
  
  <p>What I want to do with it, is to store each $cans into an array having elements and such, but this code will output all data into element 0 and so I can't call them all to use in a variable.</p>
  
  <pre><code>Array ( [0] =&gt; C ) Array ( [0] =&gt; C ) Array ( [0] =&gt; D ) Array ( [0] =&gt; A ) Array ( [0] =&gt; B ) Array ( [0] =&gt; B ) Array ( [0] =&gt; A ) Array ( [0] =&gt; C ) Array ( [0] =&gt; B ) Array ( [0] =&gt; D ) 
  </code></pre>
  
  <p>then if I replaced these codes</p>
  
  <pre><code>$cans = $rows['answer'];
  $test = array($cans);
  $ans = array();
  foreach ($test as $correct){
  $ans[] = $correct;
  </code></pre>
  
  <p>into this</p>
  
  <pre><code>echo $rows['answer'];
  </code></pre>
  
  <p>Then it will just simply print all the data like this: BCACABDDCB</p>
  
  <p>If there is a way to get all the printed output at once then I can just use str_split to split them.</p>
  
  <p>I really can't find an answer about this. Thanks in advance guys.</p>