user205376
0
Q:

php foreach get current index

$index = 0;
foreach($data as $key=>$val) {
    // Use $key as an index, or...

    // ... manage the index this way..
    echo "Index is $index\n";
    $index++;
}
1

New to Communities?

Join the community