Can't access value in array using variable to specify index
<p>I have the following code:</p>

<pre><code>$id = $_GET['id'];

echo '&lt;br&gt;' . 'id: ' . $id . '&lt;br&gt;&lt;br&gt;';

echo '&lt;pre&gt;';
            print_r($itemQtys);
echo '&lt;/pre&gt;';

echo '&lt;br&gt;' . 'itemqtys[id]: ' . $itemQtys[$id] . '&lt;br&gt;';

echo '&lt;br&gt;' . 'id: ' . $id . '&lt;br&gt;';
</code></pre>

<p>The output is:</p>

<blockquote>
  <p>id: 5</p>
  
  <p>Array<br>
   (<br>
              [5] => 12<br>
    )</p>
  
  <p>itemqtys[id]:</p>
  
  <p>id: 5</p>
</blockquote>

<p>As you can see, when I try to access the value in the array using the $id variable as the key, no value is returned. However, when I do this:</p>

<pre><code>echo '&lt;br&gt;' . 'itemqtys[5]: ' . $itemQtys[5] . '&lt;br&gt;';
</code></pre>

<p>The result is:</p>

<blockquote>
  <p>itemqtys[5]: 12</p>
</blockquote>

<p>Why can't I use a variable to specify the index in the array?</p>
