Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for-tag does not keep array indexes #46

Open
HansMayer opened this issue Apr 1, 2012 · 0 comments
Open

for-tag does not keep array indexes #46

HansMayer opened this issue Apr 1, 2012 · 0 comments

Comments

@HansMayer
Copy link

Hi,
when iterating over an array, the indexes are not kept:

$someArray = array(3=>"Three", 1=>'One',0=>'Zero Mostel', 2=>'Two');

If you're now iterating the array like this:

{% for key,value in someArray %}
{{key}}: {{value}}<br />
{% endfor %}

you get the following:

0: Three
1: One
2: Zero Mostel
3: Two

while this is expected:

3: Three
1: One
0: Zero Mostel
2: Two

Maybe using sort() instead of asort() somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant