Reputation: 145
I am programming with Velocity, but the logic is very near to C# and Java. So I got an two-dimensional array:
[0, 13], [1,1], [2,5] and so on.
Now i want to use these numbers like the following. How?
{
"country": 0,
"litres": 13
},
{
"country": 1,
"litres": 1
},
{
"country": 2,
"litres": 5
},
For example With the follow code I get 0 13 1 1 2 5
#set($start = 0)
#set($end = $list.size - 1)
#set($range = [$start..$end])
#foreach($i in $range)
#foreach($j in $range)
$list.get($i).get($j)
#end
#end
In Velocity I only can use foreach loops.
Thanks in advance!
Upvotes: 0
Views: 96
Reputation: 1530
Do you have an array (one-dimensionnal) containing couples or a two-dimensional array? In the first case I would do something like
foreach($i in $range)
country = $list.get($i).getFirst()
litres = $list.get($i).getSecond()
Upvotes: 1