I am a newbie with programming and my mind is grasping the basics of working with a php array. I found this in one of David Powers book. The code works but I can't understand how. It's a foreach loop:

foreach ($_POST as $key => $value){
$temp = is_array($value) ? $value : trim($value);
echo ${$key} = $temp;

This is a quick way of storing variables for all fields in an html form. Manually the equivalent is this:
$email = $_POST['email']

But using the foreach method the name value pairs automatically collect themselves from html form fields. But the temp refers to inputs made by users, so how does assigning the $key variable to $temp grab the form fields in the superglobal $_POST array?