I would like to get the index of the current element of an array in a loop. If I have this exemple :
<?php
$array = array('a', 'b', 'c', 'd', 'e');
foreach($array as $elem)
{
echo $elem;
}
>
How could I get the index of elem in this loop (ex: 1 for 'b') ? I tried current($array) but the return value stay at 0 in my loop but with print_r() I have this.
print_r($array);
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e )
Have you got any idea ?