foreach loops are awesome! I only have a second to post, but let me give you the jist of how they work.
They obviously loop through arrays. Throughout each iteration of the loop, you have access that a specific entry in the array. You can access that specific key and the corresponding value. So what you do is this:
foreach($array as $key => $value) {
echo "The Key is " . $key . " and the Value is " . $value . "<br>";
}
In the example above, $array is the actual array. $key is the variable that will contain the array key for each record, and $value will contain the value that that array key holds. So lets say you had the following array
0 => dogs
1 => cats
2 => horses
3 => bugs
The foreach loop above would output
The key is 0 and the Value is dogs
The key is 1 and the Value is cats
The key is 2 and the Value is horses
The key is 3 and the Value is bugs
Get it? Now, keep in mind $key and $value are the names you provide. For all php cares, you can name those whatever you want; just refer back to the name you use.
foreach($array as $number => $animal) {
echo "The Key is " . $number . " and the Value is " . $animal . "<br>";
}
This would produce the exact same output.
Hope this helped!
Cgraz