...well, I know how arrays and foreach work. It'd be easier to explain, though, if I used my own example.
I don't know what you know, so I'm going to start with the basics. A normal variable can only have one value e.g. $name = 'Bob'; but with an array, you can make a variable have as many values as you want e.g. $names = array('Bob', 'Bill, 'Robert');
If you want to print the value of a normal variable, just do echo $name and you're done. With an array, it is a little more complicated. PHP has to know which value you want to access, so each value has a key. In our $names array the key is 0 for 'Bob, 1 for 'Bill', and 2 for 'Robert'. We didn't give them these keys, PHP assigned them automatically. (And yeah PHP starts counting at 0.) So if we want to print out "Bill", for instance, we'd do echo $names;
If we don't like keys like this, we can make our own, e.g. $user = array('username' => 'stinkypete', 'firstname' = 'Peter', 'lastname' => 'Smith'); If I want to echo this guy's first name I'd do echo $user['firstname'];
Arrays can be more complicated than this. We can have what are called multidimensional arrays. This is an array with arrays in it! Here's an example:
$users = array(
'0' => array('username' => 'stinkypete', 'firstname' => 'Peter', 'lastname' => 'Smith'),
'1' => array('username' => 'sunprincess', 'firstname' => 'Jasmine', 'lastname' => 'Hanson'),
'2' => array('username' => 'hitsugaya', 'firstname' => 'Elliot', 'lastname' => 'Moon'),
(Note: You don't have to put stuff on separate lines but it makes it easier to read.)
Anyway this multidimensional array I just showed you is similar to what you get when you query the database and have results returned. You could think of key '0' as the first row, key '1' as the second, and key '2' as the third.
So, how does this all apply to foreach()? Well, once you start using multidimensional arrays, echoing all the values out (or doing whatever it is you want to do with them) would be annoying without foreach().
foreach ($users as $user)
echo '<strong>Username:</strong> '.$user['username'].' <strong>First Name:</strong> '.$user['firstname'].' <strong>Last Name:</strong> '.$user['lastname'].'<br />';
Ok, remember the keys? 0, 1, and 2? Foreach is going to go through them one by one. When it's doing a key, 0 for instance, the value of that key is going to go in $user. So, when it's doing 0, array('username' => 'stinkypete', 'firstname' => 'Peter', 'lastname' => 'Smith') gets put in $user. That's why you can do, say, echo $user['firstname'] and it will print "Peter".
So, our little foreach here is going to print out the stuff in 0, then 1, then 2. Try it for yourself so you can see.