how to change a value of $page object in loop

…… ……

$page = $paginator->getPaginate();

foreach($page->items as &$item) { $item->value = 0; }

how to change a object value in the loop, the code above can not work.

you can try

$page = $paginator->getPaginate();

foreach($page->items as &$item) { $item = 0; }

or with for

for(i=o;i>=$page.lenght;i++) { $page[i] = 0; }



812

you can try

$page = $paginator->getPaginate();

foreach($page->items as &$item) { $item = 0; }

or with for

for(i=o;i>=$page.lenght;i++) { $page[i] = 0; }

when I do this , It appears : Fatal error: An iterator cannot be used with foreach by reference in C:\xampp\htdocs\dict\app.....

In $page->items is array of models. So you can do somethink like this:

$newItems = array();
foreach ($page->items as $item) {
  $item->value = 0;
  $newItems[] = $item;
}

$page->items = $newItems;