php – Smarty reading last x numbers of rows of an array – Education Career Blog

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


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


{foreach from=$array item=row name=foo}
{if $ >= $ - 3}

Leave a Comment