title: Laravel 5.2 foreach associative array in key return index
body: <p>I have this piece oh code:</p>
  <pre><code>&lt;?php
      
  $levels = array( &quot;0&quot; =&gt; &quot;Super User&quot;, &quot;1&quot; =&gt; &quot;Administrator&quot;, &quot;10&quot; =&gt; &quot;10&quot;, &quot;20&quot; =&gt; 20, &quot;30&quot; =&gt; &quot;30&quot;, &quot;40&quot; =&gt; &quot;40&quot;, &quot;50&quot; =&gt; &quot;50&quot;, &quot;99&quot; =&gt; &quot;99 News homepage&quot; );
  
  ?&gt;
  
  &lt;select name=&quot;level&quot; id=&quot;modify_modal_level&quot;&gt;
      @foreach( $levels as $key =&gt; $val )
              &lt;option value=&quot;{{ $key }}&quot; &lt;?php echo $selected==$key ? 'selected=&quot;selected&quot;': &quot;&quot;?&gt;&gt;{{ $val }}&lt;/option&gt;
      @endforeach
  &lt;/select&gt;
  </code></pre>
  <p>Why the $key inside foreach return the INDEX of array?
  example:</p>
  <pre><code>@foreach( $levels as $key =&gt; $val )
     {{ $key }},
  @endforeach
  </code></pre>
  <p>prints out:
  1,2,3,4,5,6,7,8,</p>
  <p>instead of:
  '0','1','10','20','30','40','50','99'</p>
  <p>but the foreach loop in the $key variable MUST return the key value of the associative array, not the key index!</p>
  <p>my select results:</p>
  <pre><code>&lt;select name=&quot;level&quot; id=&quot;modify_modal_level&quot;&gt;
  &lt;option value=&quot;1&quot;&gt;Super User&lt;/option&gt;
  &lt;option value=&quot;2&quot;&gt;Administrator&lt;/option&gt;
  &lt;option value=&quot;3&quot;&gt;10&lt;/option&gt;
  ...
  &lt;option value=&quot;8&quot;&gt;99 News homepage&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  <p>instead of:</p>
  <pre><code>&lt;select name=&quot;level&quot; id=&quot;modify_modal_level&quot;&gt;
  &lt;option value=&quot;0&quot;&gt;Super User&lt;/option&gt;
  &lt;option value=&quot;1&quot;&gt;Administrator&lt;/option&gt;
  &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
  ...
  &lt;option value=&quot;99&quot;&gt;99 News homepage&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  <p>Thanks!!</p>