Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.



 
Post new topic   Reply to topic    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
OmJFJ
Smarty Rookie


Joined: 29 Jul 2016
Posts: 5

PostPosted: Sun Jul 31, 2016 5:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP