I am looping through a nested array in smarty, and each element has a status of ‘active’ or ‘inactive’. How can I detect the last element in the array that is set to active?
example code:
{foreach from=$steps item=step name=step}
{if $step.status == 'active' && ????? }
{/if}
{/foreach}
Is the array indexed numerically or by key? If numeric i think the
itemargument in your loop is the index so you could use that in your if. if its not then youll have to callcountto get the total number of items and then manually increment. or you could usearray_valuesto transform the keys to numeric before starting your loop. Not really sure how to do any of that in Smarty though.