title: How to get a value of a key in a twig array outside of a loop
body: <p>I have an array of states and a number like:</p>
  
  <p>(state, count)</p>
  
  <pre><code>states=[
  'ACT' =&gt; 25,
  'NSW' =&gt; 45,
  'VIC' =&gt; 18,
  'SA'  =&gt; 12
  ]
  </code></pre>
  
  <p>I'm trying to get the value for each state in twig (outside of a loop).</p>
  
  <p>So for each state (as a dynamic parameter) I need to get the "count" value:</p>
  
  <pre><code>{{ attribute(states, state_name).count }}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{{ attribute(states, count)}}
  </code></pre>
  
  <p>but not working.</p>
  
  <p>Any idea?</p>
  
  <p><strong>Edit:</strong>
  This code is working but can't get the value out of the loop.
  In this code I need to run the loop several times.</p>
  
  <pre><code>{% for state in states %}
     {% if state.state_name == state_name %}
         ({{ state.count }})
     {% endif %}
  {% endfor %}
  </code></pre>