Skip to content
Advertisement

How to find the foreach index?

Is it possible to find the foreach index?

in a for loop as follows:

JavaScript

$i will give you the index.

Do I have to use the for loop or is there some way to get the index in the foreach loop?

Advertisement

Answer

JavaScript

$key is the index of each $array element

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement