This question already has an answer here:
- PHP foreach loop key value 4 answers
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).
I have assoc array which looks like this:
var_dump($myArray);
array(5) {
["key1"]=> array(2) {....}
["key2"]=> array(2) {....}
["key3"]=> array(2) {....}
["key4"]=> array(2) {....}
["key5"]=> array(2) {....}
}
foreach($myArray as $key) {
echo key($myArray);
}
For example this only returns: key1key1key1key1key1
My desired output should look like: key1key2key3key4key5
I've been searching for a while but I can't find any smart solution.
Thank you :)
</div>