title: PHP Variable Passing in Foreach on same page
body: <p>I've been struggling this for a while and I simply can't figure this out. Here is my code:</p>
  
  <pre><code>&lt;?php
  
  $list = array(
  "60002" =&gt; array("name" =&gt; "Cyan Bubble Color", "info" =&gt; array("cost" =&gt; "200", "code" =&gt; "0x50ebec")),
  "65002" =&gt; array("name" =&gt; "Cyan Name Color", "info" =&gt; array("cost" =&gt; "150", "code" =&gt; "0x00cccc")),
  );
  
  foreach($list as $id =&gt;$name) {
  echo("&lt;td style=\"vertical-align:middle;\"&gt;
        &lt;a href=\"item=$id#confirm\" role=\"button\" data-toggle=\"modal\"&gt;
        Buy&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;");
  }?&gt;
  
  &lt;html&gt;
    &lt;div class="modal small hide fade" id="confirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
  &lt;div class="modal-header"&gt;
      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
      &lt;h3 id="myModalLabel"&gt;Log off before purchase&lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="modal-body"&gt;
      &lt;p class="error-text"&gt;&lt;i class="icon-warning-sign modal-icon"&gt;&lt;/i&gt;Log off all instances&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
      &lt;a href="redeem.php?item=&lt;?php echo $id; ?&gt;"&gt;&lt;button class="btn btn-danger"&gt;Buy&lt;/button&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>The main issue here is that the $id from the foreeach is not the same as the $id in the div class link. Instead the link is the end value of the foreach list.</p>