title: PHP - Using a variable as the index for a $_GET[''] statement
body: <p>I have an array, <em>anArray</em>, that I loop through, like so:</p>
  
  <pre><code>foreach ($anArray as $key) {
  
      echo $_GET[$key];
  
  }
  </code></pre>
  
  <p>I get numerous errors saying:</p>
  
  <blockquote>
    <p>Undefined index: $key</p>
  </blockquote>
  
  <p>Which is true, but I don't know how to get my PHP to recognise $key is a variable, and not just a string.</p>
  
  <p>If I print out the list of the $_GET $key => $value pairs, and a list of $anArray, they both contain at least some of the same values.</p>
  
  <p>Can anyone tell me where I'm going wrong?</p>
  
  <p>Many thanks. </p>