Answers.Body: <p>You can use the <a href="https://twig.symfony.com/doc/2.x/filters/slice.html" rel="nofollow noreferrer">slice</a> filter but it will return an array, so you either have to loop the result or access the first index</p>
  
  <pre><code>{% for item in array|slice(1, 1) %}
      {{ dump(item) }}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-13T14:00:11.010Z
Answers.LastActivityDate: 2018-07-13T14:00:11.010Z
Answers.UserDisplayName: Robin Schambach
Answers.Body: <p>I <em>think</em> you can do <code>{{ myarray[1] }}</code> or even <code>{{ myarray.1 }}</code></p>
  
  <p>A more convoluted way would be to loop through the items and on the second pass, get the value.</p>
  
  <pre><code>{% set secondValue = null %}
  {% for value in myArray %}
      {% if loop.index == 1 %}
          {% set secondValue = value %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-13T13:14:08.583Z
Answers.LastActivityDate: 2018-07-13T13:14:08.583Z
Answers.UserDisplayName: foamcow
Body: <p>I would like to select the second position in the array below. The problem is that this number is automatically changed. So I try to do this with .index function from Twig but I can not figure it out. Can someone help me?</p>
  
  <p>array (
    7296680 => 
    array (
      ...
    ),
    7296635 => 
    array (
       ...
      'url' => 'vesten',
      'title' => 'Vesten',
    ),
  )</p>
  
Tags: <templating><array><index><position>
Title: How do I target the second item in an array with Twig?
ThreadText: # How do I target the second item in an array with Twig?
  
  (Asked by: username_0 on 2018-07-13)
  
  I would like to select the second position in the array below. The problem is that this number is automatically changed. So I try to do this with .index function from Twig but I can not figure it out. Can someone help me?
  
  array (
  7296680 =>
  array (
  ...
  ),
  7296635 =>
  array (
  ...
  'url' => 'vesten',
  'title' => 'Vesten',
  ),
  )
  
  **Tags:** templating, array, index, position
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-07-13. Score: 2
  
  You can use the [slice](https://twig.symfony.com/doc/2.x/filters/slice.html) filter but it will return an array, so you either have to loop the result or access the first index
  
  ```
  {% for item in array|slice(1, 1) %}
      {{ dump(item) }}
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2018-07-13. Score: 1
  
  I *think* you can do `{{ myarray[1] }}` or even `{{ myarray.1 }}`
  
  A more convoluted way would be to loop through the items and on the second pass, get the value.
  
  ```
  {% set secondValue = null %}
  {% for value in myArray %}
      {% if loop.index == 1 %}
          {% set secondValue = value %}
      {% endif %}
  {% endfor %}
  
  ```
  
  
  ---
  
  