I'm including multiple templates in a loop by using
@include('template.included')
Before including this template I define
$page = 0;
and inside the template, multiple times it calls
$page++;
Inside the included template, the value correctly increments, however outside the template it seems like the $page variable stays the same - it's looking like @include creates it's own copy of each var you use.
I need this $page variable to update from inside those templates, and have it's value returned back to my main template - am I missing something simple?
Appreciate any suggestions!
EDIT:
My issue, for example:
$page = 0;
@include('template.included') //This calls $page++ 5 times
echo $page; //returns 0
I need $page to return 4, not 0