|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
OmJFJ Smarty Rookie
Joined: 29 Jul 2016 Posts: 5
|
Posted: Sun Jul 31, 2016 5:24 pm Post subject: |
|
|
hier mein Array:
Code: |
[== smarty ==]
$array[0].item = '1'
$array[1].item = '2'
$array[2].item = '3'
...
|
Nun möchte ich den Wert vom nächsten Index mittels einer Variable haben: (mit counter)
Code: |
[== smarty ==]
{counter assign=i start=1 print=false}
{foreach $array as $myArray}
var currentValue = {$myArray.item}; // currentValue = 1
var nextValue = {$array[$i].item}; // geht nicht, warum?
var nextValue = {$array[1].item}; // nextValue = 2
{$staticVar=1}
var nextValue = {$array[$staticVar].item}; // nextValue = 2
{counter}
{/foreach}
|
Im ersten Schleifendurchgang ist $i = 1, jedoch kann ich diese nicht für den Array Index verwenden |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|