How do I get the key of the current element in a foreach loop in C#?
foreach
For example:
foreach ($array as $key => $value) {
Alas there is no built-in way to do this. Either use a for loop or create a temp variable that you increment on each pass.