if I write a foreach loop like this, is the method all()
called every loop again or only once?
foreach(User::all() as $user) { ... }
In C# I know, the all()
function is only executed once. But in php also?
Or is it faster if I hold the data in a variable like this?
$users = User::all();
foreach($users as $user) { ...}
via Phil795