title: PHP array not extracting as expected - why is this?
body: <p>When using an array in a foreach loop</p>
  
  <pre><code>$stdlist = rtrim(trim($_POST['stdlist'], '/'), '/');
  $stdlist = explode('/' , $stdlist);
  print_r($stdlist);
  foreach($stdlist as $value)
  {
      echo "&lt;br&gt;";
      echo $_POST[$value];
  }
  </code></pre>
  
  <p>the array $stdlist is clearly working; when printed this returns:</p>
  
  <pre><code>Array ( [0] =&gt; 1 [1] =&gt; 6 [2] =&gt; 7 [3] =&gt; 8 )
  </code></pre>
  
  <p>My problem is that when I use the foreach loop to extract out of the array one value at a time, the following gets printed to the page:</p>
  
  <pre><code>4
  4
  Notice: Undefined offset: 7 in C:\Program Files\wamp\www...on line 35
  Notice: Undefined offset: 7 in C:\Program Files\wamp\www...on line 35
  </code></pre>
  
  <p>I know this isn't functioning as intended as I am expecting the following:</p>
  
  <pre><code>1
  6
  7
  8
  </code></pre>
  
  <p>Could somebody please explain why this is happening and how to fix this issue? Thanks :-)</p>