title: Laravel : I want to return the result of chunk function , to get it in the view with Ajax
body: <p>I want to return the result of chunk. The problem is , when I iterate with foreach, I put echo result it displays the result but when I want to return it , I have a blank page</p>
  
  <pre><code>$tab = array();
  
  Product::blabla -&gt;chunk (500, function($results))
  
  {
  
  
    foreach($results as $result)
  
    {
      array_push ($tab,$result);
      echo $results;// works
      return $results;// doesn't return anything
  
     }
  
  }
  
  return $tab; // to be sent to Ajax type get
  </code></pre>