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
$tab = array();
Product::blabla ->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