tags:

views:

17

answers:

2

I need to read for example last 3 items of an array in smarty. Please advice.

A: 
{foreach from=$array item=row name=foo}
{if $smarty.foreach.foo.index >= $smarty.foreach.foo.total - 3}
    {$row}
{/if}
{/foreach}
EBAGHAKI
A: 

Do this

 {assign var=lastRows value=$array|array_slice:-3}

And after this you may use $lastRows in any way you want. You should also take a look at http://www.php.net/manual/en/function.array-slice.php

Quamis