title: Wordpress PHP MySQL query with a multidimensional array
body: <p>When I run the below <code>PHP</code> in WordPress without the <code>foreach</code> I successfully get printed a multidimensional array. When I use the <code>foreach</code> it returns an <code>error 500</code> I am just trying to loop through the results so I am able to select each <code>name</code> and then push it to another array.</p>
  
  <p>If someone could assist me with looping through this array, that would be great!</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [term_taxonomy_id] =&gt; 26
              [taxonomy] =&gt; product_brand
              [name] =&gt; Authentic Cheese 
              [slug] =&gt; authentic-cheese
          )
  
      [1] =&gt; stdClass Object
          (
              [term_taxonomy_id] =&gt; 27
              [taxonomy] =&gt; product_brand
              [name] =&gt; Robot
              [slug] =&gt; robot
          )
  
  )
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>$q2 = "SELECT t.term_taxonomy_id, t.taxonomy, e.name, e.slug
  FROM wp_term_taxonomy t
  INNER JOIN wp_terms e ON t.term_taxonomy_id = e.term_id
  WHERE taxonomy = 'product_brand'";
  
  $r2 = $wpdb-&gt;get_results($q2);
  
  print_r($r2);
  
  foreach ($r2 as $row) {
      echo $row['name'];
  }
  </code></pre>