title: PHP foreach database results
body: <p>CodeIgniter question: So I select data from db and I am printing the results like this: </p>
  
  <pre><code>foreach ($query-&gt;result() as $row)
  {       
     echo $row-&gt;db_item;
  }
  </code></pre>
  
  <p>Foreach returns 3 rows and the result look like this:
      <code>010203</code>.</p>
  
  <p>How do I make it so the result should be echoed like this (each row of the result to be sliced somehow, e.g. each row of the result to be retrieved separately):</p>
  
  <pre><code>01
  02
  03
  </code></pre>
  
  <p>One last thing, if I add another line after the foreach I only retrieve the last row of the result <code>03</code> and not the same <code>010203</code>. Why is that, theoretically?</p>
  
  <pre><code>foreach ($query-&gt;result() as $row)
      {       
         echo $row-&gt;db_item;
      }
      echo $row-&gt;db_item; //this returns 01020303
  </code></pre>