Smarty:使用Array变量获取下一个索引

my array:

$array[0].item = '1'
$array[1].item = '2'
$array[2].item = '3'
...

Now I want get the Value of the Next Index: (counter methode)

{counter assign=i start=1 print=false}
{foreach $array as $myArray}
    var currentValue = {$myArray.item}; // currentValue = 1
    var nextValue = {$array[$i].item}; // doesn't work 
    {counter}
{/foreach}

The Variable $i is in the first loop exactly '1' but i cant use it for the Array as index, why?

Try to use {section}: http://www.smarty.net/docsv2/en/language.function.section.tpl

{counter start=1 print=false}
{section name=i loop=$myArray}
    var currentValue = {$myArray[i].item};
    var nextValue = {$myArray[i.index_next].item|default:''};
    {counter}
{/section}

Make sure in your php code, you are doing proper assigning:

$smarty->assign('myArray', $array);