How to current array key inside foreach : <p>In my PHP code I want to check inside foreach iteration what is the current array key (In code below: key1/key2/key3/key4/key5).</p>

<p>I have assoc array which looks like this:</p>

<p>var_dump($myArray);</p>

<p>array(5) { </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;["key1"]=> array(2) {....} </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;["key2"]=> array(2) {....} </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;["key3"]=> array(2) {....} </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;["key4"]=> array(2) {....}</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;["key5"]=> array(2) {....}</p>

<p>}</p>

<pre><code>foreach($myArray as $key) {
    echo key($myArray);
}
</code></pre>

<p>For example this only returns: key1key1key1key1key1</p>

<p>My desired output should look like: key1key2key3key4key5</p>

<p>I've been searching for a while but I can't find any smart solution.</p>

<p>Thank you :)</p>
