title: Storing values of multidimensional array into variables
body: <p>I have the following code:</p>
  
  <pre><code>$res = $db-&gt;getArticles($db);
  $hey = print_r($res, TRUE);
  echo $hey['0'];
  </code></pre>
  
  <p>Here is the code for <code>$db-&gt;getArticles</code>:</p>
  
  <pre><code>public function getArticles() {
      $array = array();
      try {
          $sth = $this-&gt;db-&gt;prepare("SELECT * FROM posts ORDER BY id");
          $sth-&gt;execute();
          foreach ($sth-&gt;fetchAll(PDO::FETCH_ASSOC) as $row) {
              $array[] = $row;
          }
          return $array;
      } catch (Exception $e) {
  
      }
  }
  </code></pre>
  
  <p>The logic is that the function queries the database and puts everything into an array. The number of rows in the table will always be pretty low, so performance isn't an issue.</p>
  
  <p>The following is the output of the first code snippet above:</p>
  
  <pre><code>echo $hey['0']; // prints "A" (without the quotes).
  echo $hey['1']; // prints "r"
  echo $hey['2']; // prints "r"
  echo $hey['3']; // prints "a"
  echo $hey['4']; // prints "y"
  </code></pre>
  
  <p>As you can see, it spells out the word "Array."</p>
  
  <p><code>echo $hey</code> prints the following:</p>
  
  <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [author] =&gt; 0 [content] =&gt; This Is a Test [publication_date] =&gt; 1380380992 ) )
  </code></pre>
  
  <p>My end goal is to store each individual value into a variable and do something with it. This would all happen inside a for loop which runs on the array so I can get information from each row.</p>
  
  <p>What am I doing wrong?</p>