WHY does it work? PHP foreach multidimensional arrays
<p>I've been reading PHP for absolute beginners. The book is getting me used to some things, but it's not really explaining how and why these things work.</p>

<p>Can anyone recommend a book/course that will not only show me how, but why as well? </p>

<p>Foe example: </p>

<pre><code>$people = array(
    'Jason' =&gt; array('gender'=&gt; 'male', 'hair'=&gt; 'brown'),
    'carly' =&gt; array('gender'=&gt; 'female', 'hair'=&gt;'blonde'),
);
foreach ($people as $name =&gt; $person){
    foreach($person as $key =&gt; $value){
        echo "$name's $key is $value. &lt;br /&gt;";
    }
}

// Output:
// Jason's gender is male. 
// Jason's hair is brown. 
// carly's gender is female.
// carly's hair is blonde.
</code></pre>

<p>Why am I using <code>$key</code> and <code>$value</code>? What do they do? Where did <code>$person</code> come from? Could I have named that anything else I wanted to?</p>
