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
2010-10-21 14:22:15
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
2010-10-21 14:46:59