title: How can I get the current array index in a foreach loop?
body: <p>How do I get the current index in a <code>foreach</code> loop?</p>
  
  <pre><code>foreach ($arr as $key =&gt; $val)
  {
      // How do I get the index?
      // How do I get the first element in an associative array?
  }
  </code></pre>