Is there a way to get the the current position of an array from within a nested array ?
I have a php script that has a for loop which cycles through an array, with in this is an nested loop which cycle through a sub array.
I can use pos() to get the position of the child array, is there anyway of getting the current position of the parent array.
I am sure there must be a way to do this, or is the best way to just create a counter?
thanks in advance
.k
If you’re using a for loop, you already have a counter. In this example, it’s $i :
If you’re actually using a foreach loop, use the syntax that gives you the key: