Forum Moderators: coopster
I am trying to show the count of each row in the loop
so it looks like this
1 one
2 two
3 three
I know how to count the values in the array but i can't get the row number next to the value when using a foreach loop.
[code]
<php
$arr = array("one", "two", "three");
$count = count($arr); // 3
for ($i=1; $i<=$count; $i++) {
echo $i; // 1 2 3
}
foreach ($arr as $value) {
echo $value . "<br />\n";
}
?>
[/code]
Thanks