title: How to store query result in array in laravel
body: <pre><code>  for($i=1;$i&lt;=3;$i++)
      {
          $data=DB::table('for_test')
          -&gt;where('for_test.id','=',$i)
          -&gt;distinct()
          -&gt;get();
      }
  </code></pre>
  
  <p>For every loop it selects a different row from ‘for_test’ table. But I cannot store them. How can I store them? As an example when I write</p>
  
  <pre><code>  foreach ($data as $datas) {
          echo $datas-&gt;name;
      }
  </code></pre>
  
  <p>How can I get three values?  </p>